diff options
author | Thomas Roessler <roessler@does-not-exist.org> | 1999-07-26 12:30:54 +0000 |
---|---|---|
committer | Thomas Roessler <roessler@does-not-exist.org> | 1999-07-26 12:30:54 +0000 |
commit | b2ab265dd42ff9672e6c7a01a480af2277c38a7a (patch) | |
tree | 6c894114a5b6ac04a24c5f971311276cc43d805c /rfc2047.c | |
parent | ba321dc70c7547bf0b13f32b1bf21c8b72cc36a5 (diff) |
Implement RFC 2231.
Diffstat (limited to 'rfc2047.c')
-rw-r--r-- | rfc2047.c | 14 |
1 files changed, 11 insertions, 3 deletions
@@ -281,15 +281,19 @@ static int rfc2047_decode_word (char *d, const char *s, size_t len) char *p = safe_strdup (s); char *pp = p; char *pd = d; + char *t; int enc = 0, filter = 0, count = 0, c1, c2, c3, c4; char *charset = NULL; - + while ((pp = strtok (pp, "?")) != NULL) { count++; switch (count) { case 2: + /* ignore language specification a la RFC 2231 */ + if ((t = strchr (pp, '*'))) + *t = '\0'; if (mutt_strcasecmp (pp, Charset) != 0) { filter = 1; @@ -316,6 +320,8 @@ static int rfc2047_decode_word (char *d, const char *s, size_t len) } else if (*pp == '=') { + if (pp[1] == 0 || pp[2] == 0) + break; /* something wrong */ *pd++ = (hexval(pp[1]) << 4) | hexval(pp[2]); len--; pp += 2; @@ -333,19 +339,21 @@ static int rfc2047_decode_word (char *d, const char *s, size_t len) { while (*pp && len > 0) { + if (pp[0] == '=' || pp[1] == 0 || pp[1] == '=') + break; /* something wrong */ c1 = base64val(pp[0]); c2 = base64val(pp[1]); *pd++ = (c1 << 2) | ((c2 >> 4) & 0x3); if (--len == 0) break; - if (pp[2] == '=') break; + if (pp[2] == 0 || pp[2] == '=') break; c3 = base64val(pp[2]); *pd++ = ((c2 & 0xf) << 4) | ((c3 >> 2) & 0xf); if (--len == 0) break; - if (pp[3] == '=') + if (pp[3] == 0 || pp[3] == '=') break; c4 = base64val(pp[3]); |