summaryrefslogtreecommitdiffstats
path: root/Lib/email
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2015-01-26 04:31:58 (GMT)
committerBenjamin Peterson <benjamin@python.org>2015-01-26 04:31:58 (GMT)
commit60a2f49c8cfeb632d38c7ffb8db622049e760a54 (patch)
tree8336202c76d0838826a8d4d4d35d3d1b97198039 /Lib/email
parentb335dfe7fa95c8c68630e8f7dc738c7b66637e87 (diff)
parent155ceaa454ad9a623cade5ed326e6e1e70ce109d (diff)
downloadcpython-60a2f49c8cfeb632d38c7ffb8db622049e760a54.zip
cpython-60a2f49c8cfeb632d38c7ffb8db622049e760a54.tar.gz
cpython-60a2f49c8cfeb632d38c7ffb8db622049e760a54.tar.bz2
merge 3.4 (#19996)
Diffstat (limited to 'Lib/email')
-rw-r--r--Lib/email/feedparser.py11
1 files changed, 10 insertions, 1 deletions
diff --git a/Lib/email/feedparser.py b/Lib/email/feedparser.py
index 0c3b572..c95b27f 100644
--- a/Lib/email/feedparser.py
+++ b/Lib/email/feedparser.py
@@ -33,7 +33,7 @@ NLCRE_eol = re.compile('(\r\n|\r|\n)\Z')
NLCRE_crack = re.compile('(\r\n|\r|\n)')
# RFC 2822 $3.6.8 Optional fields. ftext is %d33-57 / %d59-126, Any character
# except controls, SP, and ":".
-headerRE = re.compile(r'^(From |[\041-\071\073-\176]{1,}:|[\t ])')
+headerRE = re.compile(r'^(From |[\041-\071\073-\176]*:|[\t ])')
EMPTYSTRING = ''
NL = '\n'
@@ -511,6 +511,15 @@ class FeedParser:
# There will always be a colon, because if there wasn't the part of
# the parser that calls us would have started parsing the body.
i = line.find(':')
+
+ # If the colon is on the start of the line the header is clearly
+ # malformed, but we might be able to salvage the rest of the
+ # message. Track the error but keep going.
+ if i == 0:
+ defect = errors.InvalidHeaderDefect("Missing header name.")
+ self._cur.defects.append(defect)
+ continue
+
assert i>0, "_parse_headers fed line with no : and no leading WS"
lastheader = line[:i]
lastvalue = [line]