Commit 6597aa16 authored by Christian Heimes's avatar Christian Heimes

Issue #18347: ElementTree's html serializer now preserves the case of closing tags.

parents 260fbe80 54ad7e39
...@@ -742,6 +742,13 @@ class ElementTreeTest(unittest.TestCase): ...@@ -742,6 +742,13 @@ class ElementTreeTest(unittest.TestCase):
'<html><link><script>1 < 2</script></html>\n') '<html><link><script>1 < 2</script></html>\n')
self.assertEqual(serialize(e, method="text"), '1 < 2\n') self.assertEqual(serialize(e, method="text"), '1 < 2\n')
def test_issue18347(self):
e = ET.XML('<html><CamelCase>text</CamelCase></html>')
self.assertEqual(serialize(e),
'<html><CamelCase>text</CamelCase></html>')
self.assertEqual(serialize(e, method="html"),
'<html><CamelCase>text</CamelCase></html>')
def test_entity(self): def test_entity(self):
# Test entity handling. # Test entity handling.
......
...@@ -992,15 +992,15 @@ def _serialize_html(write, elem, qnames, namespaces, **kwargs): ...@@ -992,15 +992,15 @@ def _serialize_html(write, elem, qnames, namespaces, **kwargs):
# FIXME: handle boolean attributes # FIXME: handle boolean attributes
write(" %s=\"%s\"" % (qnames[k], v)) write(" %s=\"%s\"" % (qnames[k], v))
write(">") write(">")
tag = tag.lower() ltag = tag.lower()
if text: if text:
if tag == "script" or tag == "style": if ltag == "script" or ltag == "style":
write(text) write(text)
else: else:
write(_escape_cdata(text)) write(_escape_cdata(text))
for e in elem: for e in elem:
_serialize_html(write, e, qnames, None) _serialize_html(write, e, qnames, None)
if tag not in HTML_EMPTY: if ltag not in HTML_EMPTY:
write("</" + tag + ">") write("</" + tag + ">")
if elem.tail: if elem.tail:
write(_escape_cdata(elem.tail)) write(_escape_cdata(elem.tail))
......
...@@ -135,6 +135,9 @@ Core and Builtins ...@@ -135,6 +135,9 @@ Core and Builtins
Library Library
------- -------
- Issue #18347: ElementTree's html serializer now preserves the case of
closing tags.
- Issue #17261: Ensure multiprocessing's proxies use proper address. - Issue #17261: Ensure multiprocessing's proxies use proper address.
- Issue #18343: faulthandler.register() now keeps the previous signal handler - Issue #18343: faulthandler.register() now keeps the previous signal handler
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment