Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mailbox.py _fromlinepattern regexp does not support positive #44447

Closed
doko42 opened this issue Jan 12, 2007 · 2 comments
Closed

mailbox.py _fromlinepattern regexp does not support positive #44447

doko42 opened this issue Jan 12, 2007 · 2 comments
Assignees
Labels
stdlib Python modules in the Lib dir

Comments

@doko42
Copy link
Member

doko42 commented Jan 12, 2007

BPO 1633678
Nosy @akuchling, @doko42

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = 'https://github.com/akuchling'
closed_at = <Date 2007-01-22.20:55:04.000>
created_at = <Date 2007-01-12.01:14:08.000>
labels = ['library']
title = 'mailbox.py _fromlinepattern regexp does not support positive'
updated_at = <Date 2007-01-22.20:55:04.000>
user = 'https://github.com/doko42'

bugs.python.org fields:

activity = <Date 2007-01-22.20:55:04.000>
actor = 'akuchling'
assignee = 'akuchling'
closed = True
closed_date = None
closer = None
components = ['Library (Lib)']
creation = <Date 2007-01-12.01:14:08.000>
creator = 'doko'
dependencies = []
files = []
hgrepos = []
issue_num = 1633678
keywords = []
message_count = 2.0
messages = ['30990', '30991']
nosy_count = 2.0
nosy_names = ['akuchling', 'doko']
pr_nums = []
priority = 'normal'
resolution = 'fixed'
stage = None
status = 'closed'
superseder = None
type = None
url = 'https://bugs.python.org/issue1633678'
versions = ['Python 2.5']

@doko42
Copy link
Member Author

doko42 commented Jan 12, 2007

[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.

@doko42 doko42 closed this as completed Jan 12, 2007
@doko42 doko42 added the stdlib Python modules in the Lib dir label Jan 12, 2007
@doko42 doko42 closed this as completed Jan 12, 2007
@doko42 doko42 added the stdlib Python modules in the Lib dir label Jan 12, 2007
@akuchling
Copy link
Member

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!

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stdlib Python modules in the Lib dir
Projects
None yet
Development

No branches or pull requests

2 participants