Re: fixing the current email module
"Stephen J. Turnbull" <[email protected]> Fri, 09 Oct 2009 00:09:54 +0900
| Newsgroups | gmane.comp.python.mime.devel |
|---|---|
| Message-ID | <[email protected]> |
Barry Warsaw writes:
> >>> from email import message_from_string
> >>> with open('/dev/urandom') as wire:
> ... data = wire.read(1024)
> ...
# insert A
> >>> msg = message_from_string(data)
> >>> # number of headers
> ... len(msg)
> 0
> >>> len(msg.get_payload())
> 1024
> >>> msg.defects
> []
>
> This actually makes perfect sense. A message with no headers and a
> mass of 1024 bytes in its payload is RFC valid!
If you insert at A
>>> wire = "".join(chr(ord(ch) & 127) for ch in wire)
>>> # optional with reasonably high probability:
>>> wire = wire[0:512] + "\r\n" + wire[512:1024]
or similar. Otherwise not. ;-)