bug-mailutils
[Top][All Lists]
Advanced

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

[bug-mailutils] Base64 Attachments


From: matt mcdaniel
Subject: [bug-mailutils] Base64 Attachments
Date: Tue, 11 Dec 2007 11:52:07 -0500

So, I've noticed that it seems like mu_message_save_attachment(…) does not operate correctly when handling some base64 encoded attachments. I have 2 attachments. One sent in from a VersaMail client (from a Treo) and one sent in from a standard mail client. The two mails include the same original file as an attachment (a picture of penguins at the aquiarium taken from a mobile phone). I've included the text representation of the base-64 encoded attachment with the attachment's headers at the top (taken from linux's "mail" program). a.txt is from a normal mail server and when mu_message_save_attachment is called it produces the desired binary file.  b.txt is the one that was transmitted from the Treo (via it's VersaMail application). When mu_message_save_attachment is called on this attachment, it returns 0, but the binary data is not the same (it appears corrupted and a diff with the file saved from a.txt shows binary differences).


The main difference seems to be the number of characters per line (before a newline character). In a.txt it's 72 chars per line. In b.txt it's 70. It seems like every time there's 72 chars per line all is fine, but when there's 70 it corrupts up the data in decoding. I manually concatenated all of the text (removed the newlines) and the base64 encoded attachments are identical (diff shows no difference). I also loaded the entire base64-encoded ascii string of each text file into a variable in PHP (becuase it had an easy to access base64decode function), called base64decode and wrote those results to binary files. Both binary files are also identical. For kicks, here's what I did in PHP (I ran this program with a.txt and b.txt except I removed the headers in each file so that they contained only the base64 encoded attachment):

<?php
if($argc != 3){
    die("Usage: decode64 <src> <dest>\n");
}
$src  = $argv[1];
$dest = $argv[2];
echo file_put_contents($dest,base64_decode(file_get_contents($src))) . "\n";
?>

So, my point is that the base64-encoded data in each file (a.txt and b.txt ) appears to be 2 different (but proper) representations of the same binary file. Why does one fail and the other succeed? Is this a bug?

Attachment: b.txt
Description: Text document

Attachment: a.txt
Description: Text document


reply via email to

[Prev in Thread] Current Thread [Next in Thread]