summaryrefslogtreecommitdiffstats
path: root/Lib/email/message.py
diff options
context:
space:
mode:
authorR David Murray <rdmurray@bitdance.com>2011-03-17 01:11:23 (GMT)
committerR David Murray <rdmurray@bitdance.com>2011-03-17 01:11:23 (GMT)
commita215023b784eb1e23b2e91a007bc9a19750ed3c0 (patch)
treedb37b1f3345e2bf6b7c117177e3d578fb5abc3c5 /Lib/email/message.py
parent4e4326829f2997624261628081110bb87c090711 (diff)
downloadcpython-a215023b784eb1e23b2e91a007bc9a19750ed3c0.zip
cpython-a215023b784eb1e23b2e91a007bc9a19750ed3c0.tar.gz
cpython-a215023b784eb1e23b2e91a007bc9a19750ed3c0.tar.bz2
#11243: tests and fixes for handling of 'dirty data' in additional methods
Diffstat (limited to 'Lib/email/message.py')
-rw-r--r--Lib/email/message.py13
1 files changed, 8 insertions, 5 deletions
diff --git a/Lib/email/message.py b/Lib/email/message.py
index 2713bc5..922617a 100644
--- a/Lib/email/message.py
+++ b/Lib/email/message.py
@@ -48,9 +48,9 @@ def _sanitize_header(name, value):
def _splitparam(param):
# Split header parameters. BAW: this may be too simple. It isn't
# strictly RFC 2045 (section 5.1) compliant, but it catches most headers
- # found in the wild. We may eventually need a full fledged parser
- # eventually.
- a, sep, b = param.partition(';')
+ # found in the wild. We may eventually need a full fledged parser.
+ # RDM: we might have a Header here; for now just stringify it.
+ a, sep, b = str(param).partition(';')
if not sep:
return a.strip(), None
return a.strip(), b.strip()
@@ -90,6 +90,8 @@ def _formatparam(param, value=None, quote=True):
return param
def _parseparam(s):
+ # RDM This might be a Header, so for now stringify it.
+ s = ';' + str(s)
plist = []
while s[:1] == ';':
s = s[1:]
@@ -240,7 +242,8 @@ class Message:
if i is not None and not isinstance(self._payload, list):
raise TypeError('Expected list, got %s' % type(self._payload))
payload = self._payload
- cte = self.get('content-transfer-encoding', '').lower()
+ # cte might be a Header, so for now stringify it.
+ cte = str(self.get('content-transfer-encoding', '')).lower()
# payload may be bytes here.
if isinstance(payload, str):
if _has_surrogates(payload):
@@ -561,7 +564,7 @@ class Message:
if value is missing:
return failobj
params = []
- for p in _parseparam(';' + value):
+ for p in _parseparam(value):
try:
name, val = p.split('=', 1)
name = name.strip()