Re: [gmime-devel] Header folding issue



Hi evil,

I've just fixed this in git master.

Problem 1 was that the header you chose was 68 chars (the minimum to create this problem for the Subject: header) and I was using a > instead of a >= comparison to decide whether or not to try folding before the run of 'a's.

Problem 2, of course, was a bit trickier in that even with the above fix, growing that string of a's to a length longer than will fit onto a single line would still cause similar behavior to the bug you found, so what I've done is to force rfc2047 encoding even for ascii word tokens *if they are too long to fit on a single line*, thus preventing forced folding which cannot be undone by the parser.

I'll look into the other bugs you mentioned in your most recent email in a few minutes...

Jeff

On 05/09/2012 02:20 PM, evil legacy wrote:
Hey,

If a header is:
  a. longer than fold length
  b. has no obvious folding spot
(e.g a string with 70 straight "A" chars)

when it gets unfolded, there's an extra \t char in the folding spot.

code to reproduce:

<code>
	GMimeMessage *message0;
	GMimeMessage *message1;
	GMimeParser  *parser;
	GMimeStream  *stream;

	g_mime_init(0);
	
	stream = g_mime_stream_mem_new();

         message0 = g_mime_message_new(0);
         g_mime_message_set_subject(message0,
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
         g_mime_object_write_to_stream((GMimeObject *)message0, stream);

         g_mime_stream_reset(stream);

	parser = g_mime_parser_new_with_stream(stream);
	message1 = g_mime_parser_construct_message (parser);

         printf("%s\n", g_mime_message_get_subject(message0));
         printf("%s\n", g_mime_message_get_subject(message1));
<code>

result:

aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa	a


As you see, after folding an unfolding, the subject has an extra \t
before the last "a" and doesn't match the original subject.
P.S. If I introduce a space in the subject, the folding/unfolding
finds where to split it and works correctly.

(Tested with 2.4 and 2.6)

Thanks!




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