This commit is contained in:
Kovid Goyal 2017-06-13 14:42:38 +05:30
parent 5806795669
commit f3beb946d5
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -622,7 +622,7 @@ def html5_parse(raw, decoder=None, log=None, discard_namespaces=False, line_numb
raw = raw.replace('\r\n', '\n').replace('\r', '\n') raw = raw.replace('\r\n', '\n').replace('\r', '\n')
raw = replace_chars.sub('', raw) raw = replace_chars.sub('', raw)
from html5_parser import parse from html5_parser import parse
root = parse(raw, maybe_xhtml=not discard_namespaces, line_number_attr=linenumber_attribute, keep_doctype=False) root = parse(raw, maybe_xhtml=not discard_namespaces, line_number_attr=linenumber_attribute, keep_doctype=False, sanitize_names=True)
if (discard_namespaces and root.tag != 'html') or ( if (discard_namespaces and root.tag != 'html') or (
not discard_namespaces and (root.tag != '{%s}%s' % (namespaces['html'], 'html') or root.prefix)): not discard_namespaces and (root.tag != '{%s}%s' % (namespaces['html'], 'html') or root.prefix)):
raise ValueError('Failed to parse correctly, root has tag: %s and prefix: %s' % (root.tag, root.prefix)) raise ValueError('Failed to parse correctly, root has tag: %s and prefix: %s' % (root.tag, root.prefix))