summaryrefslogtreecommitdiffstats
path: root/Lib/email/Message.py
diff options
context:
space:
mode:
authorBarry Warsaw <barry@python.org>2002-07-18 23:09:09 (GMT)
committerBarry Warsaw <barry@python.org>2002-07-18 23:09:09 (GMT)
commit7aeac9180e3d6df3d5db89ee7ff5941a81dc5a5d (patch)
tree0b729e7ad55be4cb686ce85bbdf9e0f8dfc8184d /Lib/email/Message.py
parente21262ca9e286aee27741eb8bb69508a911ec10b (diff)
downloadcpython-7aeac9180e3d6df3d5db89ee7ff5941a81dc5a5d.zip
cpython-7aeac9180e3d6df3d5db89ee7ff5941a81dc5a5d.tar.gz
cpython-7aeac9180e3d6df3d5db89ee7ff5941a81dc5a5d.tar.bz2
Anthony Baxter's cleanup patch. Python project SF patch # 583190,
quoting: in non-strict mode, messages don't require a blank line at the end with a missing end-terminator. A single newline is sufficient now. Handle trailing whitespace at the end of a boundary. Had to switch from using string.split() to re.split() Handle whitespace on the end of a parameter list for Content-type. Handle whitespace on the end of a plain content-type header. Specifically, get_type(): Strip the content type string. _get_params_preserve(): Strip the parameter names and values on both sides. _parsebody(): Lots of changes as described above, with some stylistic changes by Barry (who hopefully didn't screw things up ;).
Diffstat (limited to 'Lib/email/Message.py')
-rw-r--r--Lib/email/Message.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/Lib/email/Message.py b/Lib/email/Message.py
index 5e8d32f..fb121a9 100644
--- a/Lib/email/Message.py
+++ b/Lib/email/Message.py
@@ -373,7 +373,7 @@ class Message:
value = self.get('content-type', missing)
if value is missing:
return failobj
- return paramre.split(value)[0].lower()
+ return paramre.split(value)[0].lower().strip()
def get_main_type(self, failobj=None):
"""Return the message's main content type if present."""
@@ -428,11 +428,11 @@ class Message:
for p in paramre.split(value):
try:
name, val = p.split('=', 1)
- name = name.rstrip()
- val = val.lstrip()
+ name = name.strip()
+ val = val.strip()
except ValueError:
# Must have been a bare attribute
- name = p
+ name = p.strip()
val = ''
params.append((name, val))
params = Utils.decode_params(params)