diff options
author | Jeffrey Stedfast <fejj@ximian.com> | 2003-03-15 01:44:20 +0800 |
---|---|---|
committer | Jeffrey Stedfast <fejj@src.gnome.org> | 2003-03-15 01:44:20 +0800 |
commit | 1df1d4aead3ebacf457f637c6df2a5e8539b7fbf (patch) | |
tree | 0d31b8877fc39052b20abc8434018ecaa1ef63c9 /camel/camel-mime-utils.c | |
parent | 0b82cc7a34271a145a45ff7f296304e19a9315cc (diff) | |
download | gsoc2013-evolution-1df1d4aead3ebacf457f637c6df2a5e8539b7fbf.tar.gz gsoc2013-evolution-1df1d4aead3ebacf457f637c6df2a5e8539b7fbf.tar.zst gsoc2013-evolution-1df1d4aead3ebacf457f637c6df2a5e8539b7fbf.zip |
Use header_contentid_decode() as this new function should be safer than
2003-03-13 Jeffrey Stedfast <fejj@ximian.com>
* camel-mime-part.c (process_header): Use
header_contentid_decode() as this new function should be safer
than the hack that we had before.
* camel-mime-utils.c (header_contentid_decode): New function to
try and parse a content-id string in such a way as to work around
some of the known bugs in other MIME implementations. Try to be as
"safe" as we can - ie. don't allow for more than 1 @ (since the
mailer uses "@@@%d" as a fake content-id value for parts without
content-ids) and don't allow for invalid content-type chars.
svn path=/trunk/; revision=20295
Diffstat (limited to 'camel/camel-mime-utils.c')
-rw-r--r-- | camel/camel-mime-utils.c | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/camel/camel-mime-utils.c b/camel/camel-mime-utils.c index 9513d920e3..64f28a254f 100644 --- a/camel/camel-mime-utils.c +++ b/camel/camel-mime-utils.c @@ -2629,6 +2629,73 @@ header_msgid_decode(const char *in) return header_msgid_decode_internal(&in); } +char * +header_contentid_decode (const char *in) +{ + const char *inptr = in; + gboolean at = FALSE; + GString *addr; + char *buf; + + d(printf("decoding Content-ID: '%s'\n", in)); + + header_decode_lwsp (&inptr); + + /* some lame mailers quote the Content-Id */ + if (*inptr == '"') + inptr++; + + /* make sure the content-id is not "" which can happen if we get a + * content-id such as <.@> (which Eudora likes to use...) */ + if ((buf = header_msgid_decode (inptr)) != NULL && *buf) + return buf; + + g_free (buf); + + /* ugh, not a valid msg-id - try to get something useful out of it then? */ + inptr = in; + header_decode_lwsp (&inptr); + if (*inptr == '<') { + inptr++; + header_decode_lwsp (&inptr); + } + + /* Eudora has been known to use <.@> as a content-id */ + if (!(buf = header_decode_word (&inptr)) && !strchr (".@", *inptr)) + return NULL; + + addr = g_string_new (""); + header_decode_lwsp (&inptr); + while (buf != NULL || *inptr == '.' || (*inptr == '@' && !at)) { + if (buf != NULL) { + g_string_append (addr, buf); + g_free (buf); + buf = NULL; + } + + if (!at) { + if (*inptr == '.') { + g_string_append_c (addr, *inptr++); + buf = header_decode_word (&inptr); + } else if (*inptr == '@') { + g_string_append_c (addr, *inptr++); + buf = header_decode_word (&inptr); + at = TRUE; + } + } else if (strchr (".[]", *inptr)) { + g_string_append_c (addr, *inptr++); + buf = header_decode_atom (&inptr); + } + + header_decode_lwsp (&inptr); + } + + buf = addr->str; + g_string_free (addr, FALSE); + + return buf; +} + void header_references_list_append_asis(struct _header_references **list, char *ref) { |