mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
__init__(): RFC 2046 $4.1.2 says charsets are not case sensitive.
Coerce the argument to lower case. Also, since body encodings can't be SHORTEST, default the CHARSETS failobj's second item to BASE64.
This commit is contained in:
parent
d4f7da3cd7
commit
14fc464ec9
1 changed files with 3 additions and 1 deletions
|
@ -177,13 +177,15 @@ class Charset:
|
|||
this attribute will have the same value as the input_codec.
|
||||
"""
|
||||
def __init__(self, input_charset=DEFAULT_CHARSET):
|
||||
# RFC 2046, $4.1.2 says charsets are not case sensitive
|
||||
input_charset = input_charset.lower()
|
||||
# Set the input charset after filtering through the aliases
|
||||
self.input_charset = ALIASES.get(input_charset, input_charset)
|
||||
# We can try to guess which encoding and conversion to use by the
|
||||
# charset_map dictionary. Try that first, but let the user override
|
||||
# it.
|
||||
henc, benc, conv = CHARSETS.get(self.input_charset,
|
||||
(SHORTEST, SHORTEST, None))
|
||||
(SHORTEST, BASE64, None))
|
||||
# Set the attributes, allowing the arguments to override the default.
|
||||
self.header_encoding = henc
|
||||
self.body_encoding = benc
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue