from cStringIO import StringIO
from types import ListType
-from rfc822 import unquote, quote
+from rfc822 import quote
from rfc822 import AddressList as _AddressList
from rfc822 import mktime_tz
return addrs[0]
+# rfc822.unquote() doesn't properly de-backslash-ify in Python pre-2.3.
+def unquote(str):
+ """Remove quotes from a string."""
+ if len(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
+
+
\f
# RFC2231-related functions - parameter encoding and decoding
def decode_rfc2231(s):