diff options
author | R David Murray <rdmurray@bitdance.com> | 2011-06-22 17:47:53 (GMT) |
---|---|---|
committer | R David Murray <rdmurray@bitdance.com> | 2011-06-22 17:47:53 (GMT) |
commit | 749073af13fcb389059b182290f5cbc953222681 (patch) | |
tree | 9da44b14da5872581f1655829522841dd59e1060 /Lib/email | |
parent | 11cc475be79c123be0e587b12662cc70b7518348 (diff) | |
download | cpython-749073af13fcb389059b182290f5cbc953222681.zip cpython-749073af13fcb389059b182290f5cbc953222681.tar.gz cpython-749073af13fcb389059b182290f5cbc953222681.tar.bz2 |
#1874: detect invalid multipart CTE and report it as a defect.
Diffstat (limited to 'Lib/email')
-rw-r--r-- | Lib/email/errors.py | 3 | ||||
-rw-r--r-- | Lib/email/feedparser.py | 5 |
2 files changed, 8 insertions, 0 deletions
diff --git a/Lib/email/errors.py b/Lib/email/errors.py index c2ea7d4..c04deb4 100644 --- a/Lib/email/errors.py +++ b/Lib/email/errors.py @@ -55,3 +55,6 @@ class MalformedHeaderDefect(MessageDefect): class MultipartInvariantViolationDefect(MessageDefect): """A message claimed to be a multipart but no subparts were found.""" + +class InvalidMultipartContentTransferEncodingDefect(MessageDefect): + """An invalid content transfer encoding was set on the multipart itself.""" diff --git a/Lib/email/feedparser.py b/Lib/email/feedparser.py index 60de49e..e754d89 100644 --- a/Lib/email/feedparser.py +++ b/Lib/email/feedparser.py @@ -300,6 +300,11 @@ class FeedParser: lines.append(line) self._cur.set_payload(EMPTYSTRING.join(lines)) return + # Make sure a valid content type was specified per RFC 2045:6.4. + if (self._cur.get('content-transfer-encoding', '8bit').lower() + not in ('7bit', '8bit', 'binary')): + defect = errors.InvalidMultipartContentTransferEncodingDefect() + self.policy.handle_defect(self._cur, defect) # Create a line match predicate which matches the inter-part # boundary as well as the end-of-multipart boundary. Don't push # this onto the input stream until we've scanned past the |