vaghanirahul / skpsmtpmessage

Automatically exported from code.google.com/p/skpsmtpmessage
0 stars 0 forks source link

wrong base64 crashes Thunderbird #14

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Just send a message with big file and try to open in it Thunderbird3.0b2pre 

Solution is available:
AFAIK base64 data should be splitted to lines of 64 symbols.

So solution for the problem is quite simple:
in NSData+Base64Additions.m line 
encodedString = [NSString stringWithCString:outBuffer
encoding:NSASCIIStringEncoding];

should be replaced with the following code:
        encodedString = [NSMutableString stringWithCString:outBuffer
encoding:NSASCIIStringEncoding];

        int numInsertions = ([encodedString length])/64;
        if ([encodedString length] % 64 == 0)
            numInsertions--;

        for (int i = 0; i < numInsertions; i++) {
            [encodedString insertString:@"\r\n" atIndex:(64*(i+1))+(i*2)];

Produced data doesn't crash Thunderbird.

Original issue reported on code.google.com by ninethval@gmail.com on 31 Jan 2009 at 1:47

GoogleCodeExporter commented 9 years ago
sounds like a bug in Thunderbird.

Original comment by ibaird@gmail.com on 20 Feb 2009 at 3:30

GoogleCodeExporter commented 9 years ago
Wrong answer. 
Here is quote from RFC:
As such, MIME enforces a limit on line length of base 64 encoded data to 76 
characters.

Here is link to RFC:
http://www.faqs.org/rfcs/rfc3548.html

Please re-consider the answer.

Original comment by ninethval@gmail.com on 20 Feb 2009 at 4:44

GoogleCodeExporter commented 9 years ago
Here is a full quote (pay attention to the note about SMTP):

   MIME [3] is often used as a reference for base 64 encoding.  However,
   MIME does not define "base 64" per se, but rather a "base 64
   Content-Transfer-Encoding" for use within MIME.  As such, MIME
   enforces a limit on line length of base 64 encoded data to 76
   characters.  MIME inherits the encoding from PEM [2] stating it is
   "virtually identical", however PEM uses a line length of 64
   characters.  The MIME and PEM limits are both due to limits within
   SMTP.

Original comment by ninethval@gmail.com on 20 Feb 2009 at 4:46