Bug report
Bug description:
xml.dom.minidom guards comment serialization against -- (illegal inside an XML comment): Comment.writexml raises ValueError if "--" in self.data (test testSerializeCommentNodeWithDoubleHyphen). It misses a comment whose data ends with -: the trailing - fuses with the closing --> into --->, which contains --.
import xml.dom.minidom as m
doc = m.getDOMImplementation().createDocument(None, None, None)
doc.appendChild(doc.createComment("see note-"))
out = doc.toxml() # '<?xml version="1.0" ?><!--see note--->'
m.parseString(out) # xml.parsers.expat.ExpatError: not well-formed
minidom silently emits XML it cannot reparse. The existing -- guard already takes the stance that serialization must fail loudly on comment content it cannot represent; the trailing-- case is a gap in that guard.
CPython versions tested on:
CPython main
Operating systems tested on:
Linux, macOS
Linked PRs
Bug report
Bug description:
xml.dom.minidomguards comment serialization against--(illegal inside an XML comment):Comment.writexmlraisesValueErrorif"--" in self.data(testtestSerializeCommentNodeWithDoubleHyphen). It misses a comment whose data ends with-: the trailing-fuses with the closing-->into--->, which contains--.minidom silently emits XML it cannot reparse. The existing
--guard already takes the stance that serialization must fail loudly on comment content it cannot represent; the trailing--case is a gap in that guard.CPython versions tested on:
CPython main
Operating systems tested on:
Linux, macOS
Linked PRs