This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: mailbox.py _fromlinepattern regexp does not support positive
Type: Stage:
Components: Library (Lib) Versions: Python 2.5
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: akuchling Nosy List: akuchling, doko
Priority: normal Keywords:

Created on 2007-01-12 01:14 by doko, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (2)
msg30990 - (view) Author: Matthias Klose (doko) * (Python committer) Date: 2007-01-12 01:14
[forwarded from http://bugs.debian.org/254757]

mailbox.py _fromlinepattern regexp does not support positive GMT offsets. the pattern didn't change in 2.5.

bug submitter writes:

archivemail incorrectly splits up messages in my mbox-format mail
archvies.

I use Squirrelmail, which seems to create mbox lines that look like
this:

>From mangled@clarke.tinyplanet.ca Mon Jan 26 12:29:24 2004 -0400

The "-0400" appears to be throwing it off.   If the first message of an
mbox file has such a line on it, archivemail flat out stops, saying the
file is not mbox.   

If the later messages in an mbox file are in this style, they are not
counted, and archivemail thinks that the preceding message is just kind
of long, and the decision to archive or not is broken.



I have stumbled on this bug when I wanted to archive my mails on a
Sarge system. And since my TZ is positive, the regexp did not work. I
think the correct regexp for /usr/lib/python2.3/mailbox.py should be:

    _fromlinepattern = r"From \s*[^\s]+\s+\w\w\w\s+\w\w\w\s+\d?\d\s+" \
                       r"\d?\d:\d\d(:\d\d)?(\s+[^\s]+)?\s+\d\d\d\d\s*((\+|-)\d\d\d\d)?\s*$"

This should handle positive and negative timezones in From lines. I
have tested it successfully with an email beginning with this line:

From fred@athena.olympe.fr Mon May 31 13:24:50 2004 +0200

as well as one withouth TZ reference.
msg30991 - (view) Author: A.M. Kuchling (akuchling) * (Python committer) Date: 2007-01-22 20:55
According to qmail's description of the mbox format (http://www.qmail.org/qmail-manual-html/man5/mbox.html),  the 'from' lines shouldn't contain timezone info, but may contain additional information after the date.  So I think a better change is just to add [^\s]*\s* to the end of the pattern.

Note that the docs recommend the PortableUnixMailbox class as preferable for just this reason: there's too much variation in from lines to make the strict parsing useful.

Change committed to trunk in rev. 53519, and to release25-maint in rev. 53521.  Thanks for your report!


History
Date User Action Args
2022-04-11 14:56:22adminsetgithub: 44447
2007-01-12 01:14:08dokocreate