mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-02 12:51:07 +00:00
backport from trunk ... be more tolerant when parsing buggy data.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/branches/stable@26661 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
3cd1aa9b9a
commit
d50a2f370f
2 changed files with 35 additions and 13 deletions
|
@ -1,3 +1,8 @@
|
|||
2008-06-15 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/Additions/GSMime.m: Be more tolerant of illegal data in
|
||||
quoted printable words.
|
||||
|
||||
2008-06-15 Adam Fedor <fedor@gnu.org>
|
||||
|
||||
* Version 1.16.0
|
||||
|
|
|
@ -151,19 +151,36 @@ decodeWord(unsigned char *dst, unsigned char *src, unsigned char *end, WE enc)
|
|||
{
|
||||
break;
|
||||
}
|
||||
if (('\n' == *src) || ('\r' == *src))
|
||||
{
|
||||
break;
|
||||
}
|
||||
c = isdigit(*src) ? (*src - '0') : (*src - 55);
|
||||
c <<= 4;
|
||||
src++;
|
||||
if (*src == '\0')
|
||||
{
|
||||
break;
|
||||
}
|
||||
c += isdigit(*src) ? (*src - '0') : (*src - 55);
|
||||
*dst = c;
|
||||
if (('\n' == *src) || ('\r' == *src))
|
||||
{
|
||||
break;
|
||||
}
|
||||
if (!isxdigit(src[0]) || !isxdigit(src[1]))
|
||||
{
|
||||
/* Strictly speaking the '=' must be followed by
|
||||
* two hexadecimal characters, but RFC2045 says that
|
||||
* 'A reasonable approach by a robust implementation might be
|
||||
* to include the "=" character and the following character
|
||||
* in the decoded data without any transformation'
|
||||
*/
|
||||
*dst++ = '=';
|
||||
*dst = *src;
|
||||
}
|
||||
else
|
||||
{
|
||||
int h;
|
||||
int l;
|
||||
|
||||
/* Strictly speaking only uppercase characters are legal
|
||||
* here, but we tolerate lowercase too.
|
||||
*/
|
||||
h = isdigit(*src) ? (*src - '0') : (*src - 55);
|
||||
if (h > 15) h -= 32; // lowercase a-f
|
||||
src++;
|
||||
l = isdigit(*src) ? (*src - '0') : (*src - 55);
|
||||
if (l > 15) l -= 32; // lowercase a-f
|
||||
*dst = (h << 4) + l;
|
||||
}
|
||||
}
|
||||
else if (*src == '_')
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue