diff options
| author | bwarsaw | 2000-07-25 06:12:17 +0000 |
|---|---|---|
| committer | bwarsaw | 2000-07-25 06:12:17 +0000 |
| commit | cad0694f3d232eecc317badb62405085400f442a (patch) | |
| tree | ac90748c5a4ef3563ed4ffebcfab5d844b54dd55 /Mailman/Message.py | |
| parent | d13b8618110e372e4ed4f3e7ba58f31eea470d3d (diff) | |
| download | mailman-cad0694f3d232eecc317badb62405085400f442a.tar.gz mailman-cad0694f3d232eecc317badb62405085400f442a.tar.zst mailman-cad0694f3d232eecc317badb62405085400f442a.zip | |
Diffstat (limited to 'Mailman/Message.py')
| -rw-r--r-- | Mailman/Message.py | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/Mailman/Message.py b/Mailman/Message.py index 9daad1bf4..afcae81c5 100644 --- a/Mailman/Message.py +++ b/Mailman/Message.py @@ -180,10 +180,18 @@ class Message(rfc822.Message): class OutgoingMessage(Message): def __init__(self, text=''): from Mailman.pythonlib.StringIO import StringIO - # NOTE: text if supplied must begin with valid rfc822 headers. It can - # also begin with the body of the message but in that case you better - # make sure that the first line does NOT contain a colon! - Message.__init__(self, StringIO(text)) + # Because of semantics imposed by rfc822.Message, text cannot have a + # colon on the first line because otherwise the Message class + # constructor will think the first line is an rfc822 header. This can + # severely mess up the message. If you want to set headers on this + # object, just the __setitem__ interface (i.e. msg['to']='somebody'. + # + # If text has a colon on the first line, the best thing to do is to + # prepend a blank line. + lines = string.split(text, '\n') + if string.count(lines[0], ':'): + lines.insert(0, '\n') + Message.__init__(self, StringIO(string.join(lines, '\n'))) |
