Skip to content

Commit ba97659

Browse files
committed
parsedate_tz(): Fix SF bug #552345, optional FWS between the comma and
the day in an RFC 2822 date.
1 parent 795833f commit ba97659

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

Lib/email/_parseaddr.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,16 @@ def parsedate_tz(data):
4747
Accounts for military timezones.
4848
"""
4949
data = data.split()
50-
if data[0][-1] in (',', '.') or data[0].lower() in _daynames:
50+
# The FWS after the comma after the day-of-week is optional, so search and
51+
# adjust for this.
52+
if data[0].endswith(',') or data[0].lower() in _daynames:
5153
# There's a dayname here. Skip it
5254
del data[0]
55+
else:
56+
i = data[0].rfind(',')
57+
if i < 0:
58+
return None
59+
data[0] = data[0][i+1:]
5360
if len(data) == 3: # RFC 850 date, deprecated
5461
stuff = data[0].split('-')
5562
if len(stuff) == 3:

0 commit comments

Comments
 (0)