File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -760,17 +760,19 @@ def set_boundary(self, boundary):
760760 def get_content_charset (self , failobj = None ):
761761 """Return the charset parameter of the Content-Type header.
762762
763- If there is no Content-Type header, or if that header has no charset
764- parameter, failobj is returned.
763+ The returned string is always coerced to lower case. If there is no
764+ Content-Type header, or if that header has no charset parameter,
765+ failobj is returned.
765766 """
766767 missing = []
767768 charset = self .get_param ('charset' , missing )
768769 if charset is missing :
769770 return failobj
770771 if isinstance (charset , TupleType ):
771772 # RFC 2231 encoded, so decode it, and it better end up as ascii.
772- return unicode (charset [2 ], charset [0 ]).encode ('us-ascii' )
773- return charset
773+ charset = unicode (charset [2 ], charset [0 ]).encode ('us-ascii' )
774+ # RFC 2046, $4.1.2 says charsets are not case sensitive
775+ return charset .lower ()
774776
775777 def get_charsets (self , failobj = None ):
776778 """Return a list containing the charset(s) used in this message.
You can’t perform that action at this time.
0 commit comments