diff options
author | Barry Warsaw <barry@python.org> | 2002-10-10 15:13:26 (GMT) |
---|---|---|
committer | Barry Warsaw <barry@python.org> | 2002-10-10 15:13:26 (GMT) |
commit | ee07cb1d700ef8454fe3d17f1226ad222b77f40f (patch) | |
tree | 195717087c69d3ff421dd127943a05c0f275761c /Lib/email | |
parent | 14fc464ec9b0e4ac0e62af515740e9bb0a5ea448 (diff) | |
download | cpython-ee07cb1d700ef8454fe3d17f1226ad222b77f40f.zip cpython-ee07cb1d700ef8454fe3d17f1226ad222b77f40f.tar.gz cpython-ee07cb1d700ef8454fe3d17f1226ad222b77f40f.tar.bz2 |
get_content_charset(): RFC 2046 $4.1.2 says charsets are not case
sensitive. Coerce the argument to lower case.
Diffstat (limited to 'Lib/email')
-rw-r--r-- | Lib/email/Message.py | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/Lib/email/Message.py b/Lib/email/Message.py index 87ab309..16ae120 100644 --- a/Lib/email/Message.py +++ b/Lib/email/Message.py @@ -760,8 +760,9 @@ class Message: def get_content_charset(self, failobj=None): """Return the charset parameter of the Content-Type header. - If there is no Content-Type header, or if that header has no charset - parameter, failobj is returned. + The returned string is always coerced to lower case. If there is no + Content-Type header, or if that header has no charset parameter, + failobj is returned. """ missing = [] charset = self.get_param('charset', missing) @@ -769,8 +770,9 @@ class Message: return failobj if isinstance(charset, TupleType): # RFC 2231 encoded, so decode it, and it better end up as ascii. - return unicode(charset[2], charset[0]).encode('us-ascii') - return charset + charset = unicode(charset[2], charset[0]).encode('us-ascii') + # RFC 2046, $4.1.2 says charsets are not case sensitive + return charset.lower() def get_charsets(self, failobj=None): """Return a list containing the charset(s) used in this message. |