summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1997-08-14 14:10:37 (GMT)
committerGuido van Rossum <guido@python.org>1997-08-14 14:10:37 (GMT)
commit88bb808d7700307d37692f7e658d2d4b1582e0dc (patch)
tree0df98b56931fc0b18d1b26d455e94c143b98bf5f /Lib
parent7ba3de44a214a0690ca73960f540f0a8614cfad7 (diff)
downloadcpython-88bb808d7700307d37692f7e658d2d4b1582e0dc.zip
cpython-88bb808d7700307d37692f7e658d2d4b1582e0dc.tar.gz
cpython-88bb808d7700307d37692f7e658d2d4b1582e0dc.tar.bz2
Fixed (and documented, see Doc/libmimify.tex) mime_decode_header() and
mime_encode_header().
Diffstat (limited to 'Lib')
-rwxr-xr-xLib/mimify.py10
1 files changed, 6 insertions, 4 deletions
diff --git a/Lib/mimify.py b/Lib/mimify.py
index 1e93ade..4c62c24 100755
--- a/Lib/mimify.py
+++ b/Lib/mimify.py
@@ -39,7 +39,7 @@ chrset = regex.compile('^\\(content-type:.*charset="\\)\\(us-ascii\\|iso-8859-[0
regex.casefold)
he = regex.compile('^-*$')
mime_code = regex.compile('=\\([0-9a-f][0-9a-f]\\)', regex.casefold)
-mime_head = regex.compile('=\\?iso-8859-1\\?q\\?\\([^?]+\\)\\?=',
+mime_head = regex.compile('=\\?iso-8859-1\\?q\\?\\([^? \t\n]+\\)\\?=',
regex.casefold)
repl = regex.compile('^subject:[ \t]+re: ', regex.casefold)
@@ -110,9 +110,11 @@ def mime_decode_header(line):
i = mime_head.search(line)
if i < 0:
break
- match = mime_head.group(0, 1)
- newline = newline + line[:i] + mime_decode(match[1])
- line = line[i + len(match[0]):]
+ match0, match1 = mime_head.group(0, 1)
+ # convert underscores to spaces (before =XX conversion!)
+ match1 = string.join(string.split(match1, '_'), ' ')
+ newline = newline + line[:i] + mime_decode(match1)
+ line = line[i + len(match0):]
return newline + line
def unmimify_part(ifile, ofile, decode_base64 = 0):