From 3c0939a3ef306e6d66d7cb71075f3088ebdba73e Mon Sep 17 00:00:00 2001 From: Nikolaus Schulz Date: Wed, 18 Oct 2006 01:20:05 +0000 Subject: 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. --- archivemail.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'archivemail.py') diff --git a/archivemail.py b/archivemail.py index 4341d53..26dc331 100755 --- a/archivemail.py +++ b/archivemail.py @@ -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,7 +360,8 @@ class Mbox(mailbox.UnixMailbox): if not body: break self.mbox_file.write(body) - self.mbox_file.write(os.linesep) + if not msg_has_mbox_format: + self.mbox_file.write(os.linesep) def remove(self): """Close and delete the 'mbox' mailbox file""" -- cgit v1.2.3