File tree Expand file tree Collapse file tree 2 files changed +11
-2
lines changed Expand file tree Collapse file tree 2 files changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -18,7 +18,7 @@ class HtmlResponse(TextResponse):
18
18
_content_re = _template % ('content' , r'(?P<mime>[^;]+);\s*charset=(?P<charset>[\w-]+)' )
19
19
_content2_re = _template % ('charset' , r'(?P<charset>[\w-]+)' )
20
20
21
- METATAG_RE = re .compile (r'<meta\s+%s\s+%s ' % (_httpequiv_re , _content_re ), re .I )
21
+ METATAG_RE = re .compile (r'<meta(?: \s+(?:%s|%s)){2} ' % (_httpequiv_re , _content_re ), re .I )
22
22
METATAG2_RE = re .compile (r'<meta\s+%s' % _content2_re , re .I )
23
23
24
24
@memoizemethod_noargs
Original file line number Diff line number Diff line change @@ -226,7 +226,6 @@ class HtmlResponseTest(TextResponseTest):
226
226
response_class = HtmlResponse
227
227
228
228
def test_html_encoding (self ):
229
-
230
229
body = """<html><head><title>Some page</title><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
231
230
</head><body>Price: \xa3 100</body></html>'
232
231
"""
@@ -257,6 +256,16 @@ def test_html5_meta_charset(self):
257
256
r1 = self .response_class ("http://www.example.com" , body = body )
258
257
self ._assert_response_values (r1 , 'gb2312' , body )
259
258
259
+ def test_httpequiv_meta (self ):
260
+ body = '''<html><head><meta content="text/html; charset=gb18030" http-equiv="Content-Type" /></head></html>'''
261
+ response = self .response_class ('http://example.com' , body = body )
262
+ self ._assert_response_values (response , 'gb18030' , body )
263
+
264
+ body = '''<html><head><meta http-equiv="Content-Type" content="text/html; charset=gb18030" /></head></html>'''
265
+ response = self .response_class ('http://example.com' , body = body )
266
+ self ._assert_response_values (response , 'gb18030' , body )
267
+
268
+
260
269
261
270
class XmlResponseTest (TextResponseTest ):
262
271
You can’t perform that action at this time.
0 commit comments