Re: [gmime-devel] bug in mime generation with specific filename



Jeff and Evil,

I believe the issue is that the RFC 2184 parameter decoder should not look for a charset in the "*#=" form of the parameter. Looking for one doesn't cause any problems except when the value contains a single quote, as in the test case, but in that case it eats the rest of the value.

Suggested patch attached.

Best,

Peter

On May  8, 2012, at  1:16 PM, evil legacy wrote:
Hey all,

Without further ado, here's a code snippet to reproduce the bug:

<code>
void print_mime(GMimeMessage *m)
{
    GMimeStream *stdout_stream = g_mime_stream_fs_new(0);
    g_mime_object_write_to_stream((GMimeObject *)m, stdout_stream);
}

int main(int argc, char **argv)
{
    g_mime_init(0);

    const char *filename = "Ferry Corsten - Corsten's Countdown
171-200 (nic nie brakuje).odt";

    GMimeMessage *m = g_mime_message_new(0);
    GMimePart    *p = g_mime_part_new();

    g_mime_part_set_filename(p, filename);
    g_mime_message_set_mime_part(m, (GMimeObject *)p);

    print_mime(m);

    return 0;
}
</code>

I've tried this on 2.4 and 2.6, and this is the MIME it produces:

<mime>
MIME-Version: 1.0
Content-Type: text/plain; name=
Content-Disposition: attachment; filename=odt
</mime>

As you see, the filename get truncated.

I've tried debugging it, but only got as far as param_list_format(),
It's called 4 times and if I print the 'out' GString, I see that the
first two times, the output seems fine:

out: Content-Disposition: attachment; filename*0="Ferry Corsten -
Corsten's Countdown 171-200 (nic nie brakuje)."; filename*1="odt"
out: Content-Type: text/plain; name*0="Ferry Corsten - Corsten's
Countdown 171-200 (nic nie brakuje).odt"

but the next two times, it's broken:

out: Content-Type: text/plain; name=
out: Content-Disposition: attachment; filename=odt

I hope this helps somehow,  I wanted to hear your opinion before
debugging further.

Thanks!
_______________________________________________
gmime-devel-list mailing list
gmime-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gmime-devel-list

diff --git a/gmime/gmime-param.c b/gmime/gmime-param.c
index e38dc23..6ae7f99 100644
--- a/gmime/gmime-param.c
+++ b/gmime/gmime-param.c
@@ -507,7 +507,12 @@ rfc2184_param_new (char *name, char *value, int id, gboolean encoded)
 	rfc2184->parts = g_ptr_array_new ();
 	rfc2184->next = NULL;
 	
-	rfc2184->charset = rfc2184_param_charset (&inptr, &rfc2184->lang);
+	if (encoded) {
+                rfc2184->charset = rfc2184_param_charset (&inptr, &rfc2184->lang);
+        } else {
+                rfc2184->charset = NULL;
+                rfc2184->lang = NULL;
+        }
 	
 	if (inptr == value) {
 		rfc2184_param_add_part (rfc2184, value, id, encoded);

Attachment: pgpH6eWnmQNef.pgp
Description: PGP signature



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]