Part of RFC 822 ignored by email module

Bob Kline bkline at rksystems.com
Thu Jan 20 10:08:40 EST 2011


I just noticed that the following passage in RFC 822:

         The process of moving  from  this  folded   multiple-line
         representation  of a header field to its single line represen-
         tation is called "unfolding".  Unfolding  is  accomplished  by
         regarding   CRLF   immediately  followed  by  a  LWSP-char  as
         equivalent to the LWSP-char.

is not being honored by the email module.  The following two invocations 
of message_from_string() should return the same value, but that's not 
what happens:

 >>> import email
 >>> email.message_from_string("Subject: blah").get('SUBJECT')
'blah'
 >>> email.message_from_string("Subject:\n blah").get('SUBJECT')
' blah'

Note the space in front of the second value returned, but missing from 
the first.  Can someone convince me that this is not a bug?

-- 
Bob Kline
http://www.rksystems.com
mailto:bkline at rksystems.com




More information about the Python-list mailing list