diff --git a/html5lib/ihatexml.py b/html5lib/ihatexml.py index bf17bb5e..97dcab2f 100644 --- a/html5lib/ihatexml.py +++ b/html5lib/ihatexml.py @@ -260,7 +260,7 @@ def fromXmlName(self, name): return name def escapeChar(self, char): - replacement = "U" + hex(ord(char))[2:].upper().rjust(5, "0") + replacement = "U%05X" % ord(char) self.replaceCache[char] = replacement return replacement diff --git a/html5lib/tests/test_parser2.py b/html5lib/tests/test_parser2.py index 20bbdf31..2352190c 100644 --- a/html5lib/tests/test_parser2.py +++ b/html5lib/tests/test_parser2.py @@ -1,10 +1,11 @@ from __future__ import absolute_import, division, unicode_literals import io +import warnings from . import support # flake8: noqa from html5lib import html5parser -from html5lib.constants import namespaces +from html5lib.constants import namespaces, DataLossWarning from html5lib import treebuilders import unittest @@ -16,6 +17,10 @@ class MoreParserTests(unittest.TestCase): def setUp(self): self.dom_tree = treebuilders.getTreeBuilder("dom") + try: + self.lxml_tree = treebuilders.getTreeBuilder("lxml") + except ImportError: + self.lxml_tree = None def test_assertDoctypeCloneable(self): parser = html5parser.HTMLParser(tree=self.dom_tree) @@ -27,6 +32,18 @@ def test_line_counter(self): parser = html5parser.HTMLParser(tree=self.dom_tree) parser.parse("
\nx\n>\n
") + def test_ihatexml(self): + if not self.lxml_tree: + return + parser = html5parser.HTMLParser(tree=self.lxml_tree) + with warnings.catch_warnings(record=True) as w: + warnings.simplefilter("always") + + parser.parse(b'

Witam wszystkich') + + self.assertEqual(len(w), 1) + self.assertTrue(issubclass(w[-1].category, DataLossWarning)) + def test_namespace_html_elements_0_dom(self): parser = html5parser.HTMLParser(tree=self.dom_tree, namespaceHTMLElements=True) doc = parser.parse("") pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy