mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
gh-95087: Fix IndexError in parsing invalid date in the email module (GH-95201)
Co-authored-by: wouter bolsterlee <wouter@bolsterl.ee>
(cherry picked from commit ea5ed0ba51
)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
This commit is contained in:
parent
49d038496e
commit
3ec139fa4d
4 changed files with 60 additions and 23 deletions
|
@ -95,6 +95,8 @@ def _parsedate_tz(data):
|
|||
return None
|
||||
data = data[:5]
|
||||
[dd, mm, yy, tm, tz] = data
|
||||
if not (dd and mm and yy):
|
||||
return None
|
||||
mm = mm.lower()
|
||||
if mm not in _monthnames:
|
||||
dd, mm = mm, dd.lower()
|
||||
|
@ -110,6 +112,8 @@ def _parsedate_tz(data):
|
|||
yy, tm = tm, yy
|
||||
if yy[-1] == ',':
|
||||
yy = yy[:-1]
|
||||
if not yy:
|
||||
return None
|
||||
if not yy[0].isdigit():
|
||||
yy, tz = tz, yy
|
||||
if tm[-1] == ',':
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue