[Email-SIG] Messages that start with '>'

Barry Warsaw barry at python.org
Mon Nov 29 02:34:48 CET 2004


On Sun, 2004-11-28 at 19:07, Tony Meyer wrote:
> A change in email 3.0 is that messages that start with '>' are considered to
> be all body and no header, e.g:
> 
> >>> import email
> >>> email.__version__
> '2.5.5'
> >>> s = '>From 6r331g9 at bigfoot.com  Fri Jan 23 11:31:44
> 2004\r\nSubject:test\r\n\r\nTest\r\n'
> >>> m = email.message_from_string(s)
> >>> m.keys()
> ['>From 6r331g9 at bigfoot.com  Fri Jan 23 11', 'Subject']
> >>> m.as_string()
> '>From 6r331g9 at bigfoot.com  Fri Jan 23 11: 31:44 2004\nSubject:
> test\n\nTest\r\n'
> 
> >>> import email
> >>> email.__version__
> '3.0b1'
> >>> s = '>From 6r331g9 at bigfoot.com  Fri Jan 23 11:31:44
> 2004\r\nSubject:test\r\n\r\nTest\r\n'
> >>> m = email.message_from_string(s)
> >>> m.keys()
> []
> >>> m.as_string()
> '\n>From 6r331g9 at bigfoot.com  Fri Jan 23 11:31:44
> 2004\r\nSubject:test\r\n\r\nTest\r\n'
> 
> Is this deliberate?  I don't know (and haven't checked) whether it's valid
> to start a message like this, but one of my POP servers does (it puts a
> >From header at the start of any message).  If this is deliberate, I'll just
> strip that off before doing message_from_string, but if it's not, then I
> guess it needs to be fixed, and I'll open a tracker for it.

It's not valid to start a message with ">From".  Strictly speaking, RFC
2822 doesn't say anything about the "Unix-From" line that can start
messages in mbox formats, but the parsers in email 2.5 and 3.0 know how
to parse them.  However the test is that the line starts exactly with
"From ".

If you look closely enough at the email 2.5 example, the parser thought
the >From line was a normal RFC 2822 header, and split it at the first
colon -- inside the time string!  So that's clearly broken.

I think email 3.0 is doing the right thing.

-Barry

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 307 bytes
Desc: This is a digitally signed message part
Url : http://mail.python.org/pipermail/email-sig/attachments/20041128/5046dde3/attachment.pgp


More information about the Email-SIG mailing list