Be more tolerant of buggy emails.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@26660 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-MacDonald 2008-06-15 09:16:08 +00:00
parent 97b5e1c179
commit 41fd7f1afb
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-13 Richard Frith-Macdonald <rfm@gnu.org>
* Source/Additions/Unicode.m: Fix incorrect adjustment of buffer

View file

@ -155,15 +155,32 @@ decodeWord(unsigned char *dst, unsigned char *src, unsigned char *end, WE enc)
{
break;
}
c = isdigit(*src) ? (*src - '0') : (*src - 55);
c <<= 4;
src++;
if (*src == '\0')
if (!isxdigit(src[0]) || !isxdigit(src[1]))
{
break;
/* 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;
}
c += isdigit(*src) ? (*src - '0') : (*src - 55);
*dst = c;
}
else if (*src == '_')
{