aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNikolaus Schulz <microschulz@web.de>2006-10-18 01:20:05 +0000
committerNikolaus Schulz <microschulz@web.de>2006-10-18 01:20:05 +0000
commit3c0939a3ef306e6d66d7cb71075f3088ebdba73e (patch)
tree7744609b7e9be61c19caddd3a612d4303e3762a0
parentf4c6017d32cf01a0f27a705f5ed2d4e9c4ee98d0 (diff)
downloadarchivemail-3c0939a3ef306e6d66d7cb71075f3088ebdba73e.tar.gz
archivemail-3c0939a3ef306e6d66d7cb71075f3088ebdba73e.tar.bz2
archivemail-3c0939a3ef306e6d66d7cb71075f3088ebdba73e.zip
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.
-rwxr-xr-xarchivemail.py10
1 files changed, 7 insertions, 3 deletions
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"""