[ python-Bugs-964433 ] email package uses \n to rebuild content of a message

SourceForge.net noreply at sourceforge.net
Tue Jun 1 21:57:31 EDT 2004


Bugs item #964433, was opened at 2004-06-01 12:57
Message generated for change (Settings changed) made by montanaro
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=964433&group_id=5470

Category: Extension Modules
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Marco Bizzarri (emmebi)
>Assigned to: Barry A. Warsaw (bwarsaw)
Summary: email package uses \n to rebuild content of a message

Initial Comment:
As stated, the email.Parser class uses '\n' to add the 
firstbodyline to the rest of the message. This is done 
*AFTER* the splitlines() have been used to remove the 
first line from the body of a multipart message. 
 
Even though this is not a problem in many cases, it can 
be a great problem when you are dealing with signed 
files, as in my case. 
 
I've indeed a multipart message where I have: 
 
a pdf file 
 
a pkcs7 signature 
 
 
If I use the parser to analyze the message, the pdf file 
is actually one byte less, because the original file was 
\r\n terminated, rather than \n. When the parser tries 
to parse, it splits the first line (containing the 
%PDF1.4\r\n), and translates it to %PDF1.4, and then it 
is joined to the rest of the PDF file using a simple \n. In 
this way, the file is exactly one byte less of the original 
file, and, therefore, the signature can't be verified. 
 
I think we could avoid this problem using a  
 
splitlines(1)[0][:-1] 
 
which would keep the original \r\n, remove the \n, 
which can then be safely added. 

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=964433&group_id=5470



More information about the Python-bugs-list mailing list