summaryrefslogtreecommitdiffstats
path: root/Lib/email
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2022-07-25 06:17:25 (GMT)
committerGitHub <noreply@github.com>2022-07-25 06:17:25 (GMT)
commitea5ed0ba51c10cfdde7651a475438551964dfdfc (patch)
tree3f427ac4b9f85eafd0a9fbeb2ab8fec7035a6504 /Lib/email
parent5956de16cd00e7e1cf5cbf3d7b4a930eaa928321 (diff)
downloadcpython-ea5ed0ba51c10cfdde7651a475438551964dfdfc.zip
cpython-ea5ed0ba51c10cfdde7651a475438551964dfdfc.tar.gz
cpython-ea5ed0ba51c10cfdde7651a475438551964dfdfc.tar.bz2
gh-95087: Fix IndexError in parsing invalid date in the email module (GH-95201)
Co-authored-by: wouter bolsterlee <wouter@bolsterl.ee>
Diffstat (limited to 'Lib/email')
-rw-r--r--Lib/email/_parseaddr.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/Lib/email/_parseaddr.py b/Lib/email/_parseaddr.py
index ba5ad5a..febe411 100644
--- a/Lib/email/_parseaddr.py
+++ b/Lib/email/_parseaddr.py
@@ -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] == ',':