unquote(): Didn't properly de-backslash-ify. This patch (adapted from
Quinn Dunkan's mimelib SF patch #573204) fixes the problem.
diff --git a/Lib/rfc822.py b/Lib/rfc822.py
index 3d9e13f..4f69b22 100644
--- a/Lib/rfc822.py
+++ b/Lib/rfc822.py
@@ -477,9 +477,9 @@
def unquote(str):
"""Remove quotes from a string."""
if len(str) > 1:
- if str[0] == '"' and str[-1:] == '"':
- return str[1:-1]
- if str[0] == '<' and str[-1:] == '>':
+ if str.startswith('"') and str.endswith('"'):
+ return str[1:-1].replace('\\\\', '\\').replace('\\"', '"')
+ if str.startswith('<') and str.endswith('>'):
return str[1:-1]
return str