File tree Expand file tree Collapse file tree 1 file changed +16
-5
lines changed Expand file tree Collapse file tree 1 file changed +16
-5
lines changed Original file line number Diff line number Diff line change @@ -18,11 +18,22 @@ def __iter__(self):
18
18
19
19
elif type == "EmptyTag" :
20
20
if token ["name" ].lower () == "meta" :
21
- # replace charset with actual encoding
22
- for i ,(name ,value ) in enumerate (token ["data" ]):
23
- if name == 'charset' :
24
- token ["data" ][i ] = (token ["data" ][i ][0 ], self .encoding )
25
- meta_found = True
21
+ # replace charset with actual encoding
22
+ has_http_equiv_content_type = False
23
+ content_index = - 1
24
+ for i ,(name ,value ) in enumerate (token ["data" ]):
25
+ if name .lower () == 'charset' :
26
+ token ["data" ][i ] = (u'charset' , self .encoding )
27
+ meta_found = True
28
+ break
29
+ elif name == 'http-equiv' and value .lower () == 'content-type' :
30
+ has_http_equiv_content_type = True
31
+ elif name == 'content' :
32
+ content_index = i
33
+ else :
34
+ if has_http_equiv_content_type and content_index >= 0 :
35
+ token ["data" ][content_index ] = (u'content' , u'text/html; charset=%s' % self .encoding )
36
+ meta_found = True
26
37
27
38
elif token ["name" ].lower () == "head" and not meta_found :
28
39
# insert meta into empty head
You can’t perform that action at this time.
0 commit comments