]> git.phdru.name Git - mimedecode.git/commitdiff
Decode parameters on output
authorOleg Broytman <phd@phdru.name>
Mon, 1 Aug 2016 22:20:10 +0000 (01:20 +0300)
committerOleg Broytman <phd@phdru.name>
Mon, 1 Aug 2016 22:20:10 +0000 (01:20 +0300)
Python3's email doesn't allow to store non-unicode header parameters so
decode parameters on output.

mimedecode.py

index 62097e4808096650298dfe1070bde0e8da690c44..25d3db0efe83e1e5288442a79291acec9ca06eca 100755 (executable)
@@ -32,7 +32,11 @@ def output_headers(msg):
     for key, value in msg.items():
         output(key)
         output(": ")
-        output(value)
+        value = value.split(';', 1)
+        output(value[0])
+        if len(value) == 2:
+            output(";")
+            output(_decode_header(value[1], strip=False))
         output(os.linesep)
     output(os.linesep) # End of headers