1
0
Fork 0
mirror of https://git.code.sf.net/p/archivemail/code synced 2024-12-23 00:06:43 +00:00

When writing messages to mboxes, append os.linesep and mangle From_ only if the

message source is not an mbox-format folder.  
Attempts to fix broken mbox-formatted input are only asking for trouble, and
that's not our job anyway.
This commit is contained in:
Nikolaus Schulz 2006-10-18 01:20:05 +00:00
parent f4c6017d32
commit 3c0939a3ef

View file

@ -335,7 +335,10 @@ class Mbox(mailbox.UnixMailbox):
vprint("saving message to file '%s'" % self.mbox_file_name)
unix_from = msg.unixfrom
if not unix_from:
if unix_from:
msg_has_mbox_format = True
else:
msg_has_mbox_format = False
unix_from = make_mbox_from(msg)
self.mbox_file.write(unix_from)
assert(msg.headers)
@ -348,7 +351,7 @@ class Mbox(mailbox.UnixMailbox):
linebuf = ""
while 1:
body = msg.fp.read(options.read_buffer_size)
if options.mangle_from:
if (not msg_has_mbox_format) and options.mangle_from:
# Be careful not to break pattern matching
splitindex = body.rfind(os.linesep)
nicebody = linebuf + body[:splitindex]
@ -357,6 +360,7 @@ class Mbox(mailbox.UnixMailbox):
if not body:
break
self.mbox_file.write(body)
if not msg_has_mbox_format:
self.mbox_file.write(os.linesep)
def remove(self):