Re: [gmime-devel] Email parsing functions flawed and not practical to use
- From: Damian Pietras <daper daper net>
- To: Jeffrey Stedfast <fejj novell com>
- Cc: gmime-devel-list gnome org
- Subject: Re: [gmime-devel] Email parsing functions flawed and not practical to use
- Date: Thu, 26 Aug 2010 15:00:41 +0200
On Thu, Aug 26, 2010 at 02:34:42PM +0200, Damian Pietras wrote:
> > The good news is that I *think* that the following example should be
> > doable...
> > Email: "=?ISO-8859-2?Q?TEST?=" <p p org>
> >
> > This last one will likely require changes to header_decode_phrase().
> > I'll try looking into this one in the next few days.
>
> I think it's just matter of unquoting strings before decoding encoded
> words. _internet_address_decode_name() should only do decoding,
> unquoting should be done only in decode_address(). Since it uses
> decode_word() that handles unquoting it should work, but I don't know
> why it's not true.
Attached is my proposition (a patch against your patched version).
diff -rup gmime-2.4.16/gmime/internet-address.c gmime-2.4.16-fix-1/gmime/internet-address.c
--- gmime-2.4.16/gmime/internet-address.c 2010-08-26 14:54:44.000000000 +0200
+++ gmime-2.4.16-fix-1/gmime/internet-address.c 2010-08-26 14:53:05.000000000 +0200
@@ -1362,7 +1362,6 @@ _internet_address_decode_name (InternetA
/* decode the phrase */
value = g_mime_utils_header_decode_phrase (phrase);
- g_mime_utils_unquote_string (value);
g_free (ia->name);
ia->name = value;
g_free (buf);
@@ -1510,8 +1509,18 @@ decode_address (const char **in)
* tokens that make up this name phrase.
**/
while (*inptr) {
- if ((word = decode_word (&inptr)))
- g_string_append_len (name, word, (size_t) (inptr - word));
+ if ((word = decode_word (&inptr))) {
+ size_t len = inptr - word;
+
+ if (*word == '"') {
+ char *buf = g_strndup (word, len);
+ g_mime_utils_unquote_string (buf);
+ g_string_append (name, buf);
+ g_free (buf);
+ }
+ else
+ g_string_append_len (name, word, len);
+ }
if (word) {
check_lwsp:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]