Bugs item #1155362, was opened at 2005-03-02 23:03
Message generated for change (Comment added) made by tzot
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1155362&group_id=5470
Category: Python Library
Group: Python 2.3
Status: Open
Resolution: None
Priority: 5
Submitted By: TH (therve)
Assigned to: Barry A. Warsaw (bwarsaw)
Summary: Bugs in parsedate_tz
Initial Comment:
The parsing in emails is incomplete in both rfc822.py
and _parseaddr.py.
For example, "Wed, 02 Mar 2005 09:26:53+0800" is parsed
but "Wed, 02 Mar 2005 09:26:53-0800" is not.
The problem is clear by watching the code : only "+"
timezones are corrected.
Following a patch :
Index : _parseaddr.py
----------------------------------------------------------------
@@ -60,7 +66,11 @@ def parsedate_tz(data):
if i > 0:
data[3:] = [s[:i], s[i+1:]]
else:
- data.append('') # Dummy tz
+ i = s.find('-')
+ if i > 0:
+ data[3:] = [s[:i], s[i:]]
+ else:
+ data.append('') # Dummy tz
if len(data) < 5:
return None
data = data[:5]
----------------------------------------------------------------
----------------------------------------------------------------------
Comment By: Christos Georgiou (tzot)
Date: 2005-03-20 13:48
Message:
Logged In: YES
user_id=539787
Note that parsedate_tz as of current parses correctly "Wed,
02 Mar 2005 09:26:53 -0800" (space before '-'), because
data.split() in line 43 produces five parts: [dow, date,
month, year, time, timezone] (reduced to four by removing
initial dow). The function includes a special check for
"+" in the time part, and this patch adds the "-" check.
I didn't find any date header in my whole email and
newsgroup archive (12095 messages) missing the space before
[-+]. However, if mail clients or servers exist that
produce such date headers, patch should be applied and bug
closed.
Notes:
Some test should be added too. I updated
test_parsedate_no_dayofweek (line 2076 of
lib/email/test/test_email.py) adding same test dropping the
space before '-', and test fails before patch, succeeds
after patch. Perhaps a separate test case should be included.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1155362&group_id=5470
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com