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:
Richard Frith-MacDonald 2008-06-15 09:19:10 +00:00
parent 3cd1aa9b9a
commit d50a2f370f
2 changed files with 35 additions and 13 deletions

View file

@ -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> 2008-06-15 Adam Fedor <fedor@gnu.org>
* Version 1.16.0 * Version 1.16.0

View file

@ -151,19 +151,36 @@ decodeWord(unsigned char *dst, unsigned char *src, unsigned char *end, WE enc)
{ {
break; break;
} }
if (('\n' == *src) || ('\r' == *src)) if (('\n' == *src) || ('\r' == *src))
{ {
break; break;
} }
c = isdigit(*src) ? (*src - '0') : (*src - 55); if (!isxdigit(src[0]) || !isxdigit(src[1]))
c <<= 4; {
src++; /* Strictly speaking the '=' must be followed by
if (*src == '\0') * two hexadecimal characters, but RFC2045 says that
{ * 'A reasonable approach by a robust implementation might be
break; * to include the "=" character and the following character
} * in the decoded data without any transformation'
c += isdigit(*src) ? (*src - '0') : (*src - 55); */
*dst = c; *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 == '_') else if (*src == '_')
{ {