Christian Heimes avatar Christian Heimes committed df79735

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

Comments (0)

Files changed (3)

Lib/test/test_xml_etree.py

                 '<html><link><script>1 < 2</script></html>\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):
         # Test entity handling.
 

Lib/xml/etree/ElementTree.py

                     # FIXME: handle boolean attributes
                     write(" %s=\"%s\"" % (qnames[k], v))
             write(">")
-            tag = tag.lower()
+            ltag = tag.lower()
             if text:
-                if tag == "script" or tag == "style":
+                if ltag == "script" or ltag == "style":
                     write(text)
                 else:
                     write(_escape_cdata(text))
             for e in elem:
                 _serialize_html(write, e, qnames, None)
-            if tag not in HTML_EMPTY:
+            if ltag not in HTML_EMPTY:
                 write("</" + tag + ">")
     if elem.tail:
         write(_escape_cdata(elem.tail))
 Library
 -------
 
+- Issue #18347: ElementTree's html serializer now preserves the case of
+  closing tags.
+
 - Issue #17261: Ensure multiprocessing's proxies use proper address.
 
 - Issue #18343: faulthandler.register() now keeps the previous signal handler
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.