mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix #995553 (Add html injects bad meta http-equiv="Content-Type" tag?)
This commit is contained in:
parent
6d0b2ec553
commit
cc91807ffa
@ -361,9 +361,11 @@ def parse_html(data, log=None, decoder=None, preprocessor=None,
|
|||||||
# Remove any encoding-specifying <meta/> elements
|
# Remove any encoding-specifying <meta/> elements
|
||||||
for meta in META_XP(data):
|
for meta in META_XP(data):
|
||||||
meta.getparent().remove(meta)
|
meta.getparent().remove(meta)
|
||||||
etree.SubElement(head, XHTML('meta'),
|
meta = etree.SubElement(head, XHTML('meta'),
|
||||||
attrib={'http-equiv': 'Content-Type',
|
attrib={'http-equiv': 'Content-Type'})
|
||||||
'content': '%s; charset=utf-8' % XHTML_NS})
|
meta.set('content', 'text/html; charset=utf-8') # Ensure content is second
|
||||||
|
# attribute
|
||||||
|
|
||||||
# Ensure has a <body/>
|
# Ensure has a <body/>
|
||||||
if not xpath(data, '/h:html/h:body'):
|
if not xpath(data, '/h:html/h:body'):
|
||||||
body = xpath(data, '//h:body')
|
body = xpath(data, '//h:body')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user