diff options
author | R. David Murray <rdmurray@bitdance.com> | 2010-12-24 22:36:49 +0000 |
---|---|---|
committer | R. David Murray <rdmurray@bitdance.com> | 2010-12-24 22:36:49 +0000 |
commit | dfd7eb0ba2f3296f28028970e395e38f3ae9eedc (patch) | |
tree | 02ded19904da4eeea1f27afcaf6b042734348188 /Lib/email/message.py | |
parent | ddf53709eedd94450cc95c3ea0758c621790193d (diff) | |
download | cpython-git-dfd7eb0ba2f3296f28028970e395e38f3ae9eedc.tar.gz |
#1693546: don't add quotes around RFC 2231 encoded values.
The RFC is bit hard to understand on this point, but the examples
clearly show that parameter values that are encoded according
to its charset/language rules don't have surrounding quotes, and
the ABNF does not allow for quotes. So when we produce such
encoded values, we no longer add quotes.
Diffstat (limited to 'Lib/email/message.py')
-rw-r--r-- | Lib/email/message.py | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/Lib/email/message.py b/Lib/email/message.py index 8d68c093cc..d2483cacf6 100644 --- a/Lib/email/message.py +++ b/Lib/email/message.py @@ -66,17 +66,19 @@ def _formatparam(param, value=None, quote=True): if value is not None and len(value) > 0: # A tuple is used for RFC 2231 encoded parameter values where items # are (charset, language, value). charset is a string, not a Charset - # instance. + # instance. RFC 2231 encoded values are never quoted, per RFC. if isinstance(value, tuple): # Encode as per RFC 2231 param += '*' value = utils.encode_rfc2231(value[2], value[0], value[1]) + return '%s=%s' % (param, value) else: try: value.encode('ascii') except UnicodeEncodeError: param += '*' value = utils.encode_rfc2231(value, 'utf-8', '') + return '%s=%s' % (param, value) # BAW: Please check this. I think that if quote is set it should # force quoting even if not necessary. if quote or tspecials.search(value): |