summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1997-07-25 15:20:52 (GMT)
committerGuido van Rossum <guido@python.org>1997-07-25 15:20:52 (GMT)
commit9a876a45002f7d3b4c57a8b09706d1b69040a948 (patch)
tree9d886a35bd1eef951d6c5fad58f0b1a70cdeece9 /Lib
parent4e5cbcf5afa411d654983cd4cf8c99739b935b26 (diff)
downloadcpython-9a876a45002f7d3b4c57a8b09706d1b69040a948.zip
cpython-9a876a45002f7d3b4c57a8b09706d1b69040a948.tar.gz
cpython-9a876a45002f7d3b4c57a8b09706d1b69040a948.tar.bz2
Tweaks by Lars Wirzenius to parse some more forms of illegal dates:
the comma after the day name is optional if it is a recognized day name; and the date and month may be swapped. Thus, the following two test dates will now be parsed correctly: Thu, Feb 13 12:16:57 1992 Thu Feb 13 12:16:57 1992
Diffstat (limited to 'Lib')
-rw-r--r--Lib/rfc822.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/Lib/rfc822.py b/Lib/rfc822.py
index f34f0b6..b42eaec 100644
--- a/Lib/rfc822.py
+++ b/Lib/rfc822.py
@@ -397,6 +397,7 @@ def parseaddr(address):
_monthnames = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul',
'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
+_daynames = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
# The timezone table does not include the military time zones defined
# in RFC822, other than Z. According to RFC1123, the description in
@@ -414,7 +415,7 @@ _timezones = {'UT':0, 'UTC':0, 'GMT':0, 'Z':0,
def parsedate_tz(data):
data = string.split(data)
- if data[0][-1] == ',':
+ if data[0][-1] == ',' or data[0] in _daynames:
# There's a dayname here. Skip it
del data[0]
if len(data) == 3: # RFC 850 date, deprecated
@@ -433,7 +434,9 @@ def parsedate_tz(data):
data = data[:5]
[dd, mm, yy, tm, tz] = data
if not mm in _monthnames:
- return None
+ dd, mm, yy, tm, tz = mm, dd, tm, yy, tz
+ if not mm in _monthnames:
+ return None
mm = _monthnames.index(mm)+1
tm = string.splitfields(tm, ':')
if len(tm) == 2: