[PATCH] D68986: [LNT] Python 3 support: adapt XML parsing with extra entities
Thomas Preud'homme via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Dec 5 04:11:23 PST 2019
thopre updated this revision to Diff 232305.
thopre added a comment.
Rebase earlier
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D68986/new/
https://reviews.llvm.org/D68986
Files:
tests/server/ui/V4Pages.py
Index: tests/server/ui/V4Pages.py
===================================================================
--- tests/server/ui/V4Pages.py
+++ tests/server/ui/V4Pages.py
@@ -109,10 +109,12 @@
def get_xml_tree(html_string):
try:
- parser = ET.XMLParser()
- parser.parser.UseForeignDTD(True)
- parser.entity.update((x, unichr(i)) for x, i in name2codepoint.items())
- tree = ET.fromstring(html_string, parser=parser)
+ entities_defs = []
+ for x, i in name2codepoint.items():
+ entities_defs.append(' <!ENTITY {x} "&#{i};">'.format(**locals()))
+ docstring = "<!DOCTYPE html [\n{}\n]>".format('\n'.join(entities_defs))
+ html_string = html_string.replace("<!DOCTYPE html>", docstring, 1)
+ tree = ET.fromstring(html_string)
except: # noqa FIXME: figure out what we expect this to throw.
dump_html(html_string)
raise
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D68986.232305.patch
Type: text/x-patch
Size: 915 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191205/ebee8083/attachment.bin>
More information about the llvm-commits
mailing list