unquote(): Didn't properly de-backslash-ify. This patch (adapted from

Quinn Dunkan's mimelib SF patch #573204) fixes the problem.
This commit is contained in:
Barry Warsaw 2002-09-11 02:32:14 +00:00
parent bc6edac8df
commit 4e09d5c6d6

View file

@ -477,9 +477,9 @@ class Message:
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