mirror of https://github.com/python/cpython
Issue #1390: Raise ValueError in toxml when an invalid comment would
otherwise be produced.
This commit is contained in:
parent
8c255e4173
commit
27e4a179f2
|
@ -1314,6 +1314,11 @@ class MinidomTest(unittest.TestCase):
|
||||||
for i in range(len(n1.childNodes)):
|
for i in range(len(n1.childNodes)):
|
||||||
stack.append((n1.childNodes[i], n2.childNodes[i]))
|
stack.append((n1.childNodes[i], n2.childNodes[i]))
|
||||||
|
|
||||||
|
def testSerializeCommentNodeWithDoubleHyphen(self):
|
||||||
|
doc = create_doc_without_doctype()
|
||||||
|
doc.appendChild(doc.createComment("foo--bar"))
|
||||||
|
self.assertRaises(ValueError, doc.toxml)
|
||||||
|
|
||||||
def test_main():
|
def test_main():
|
||||||
run_unittest(MinidomTest)
|
run_unittest(MinidomTest)
|
||||||
|
|
||||||
|
|
|
@ -1128,6 +1128,8 @@ class Comment(Childless, CharacterData):
|
||||||
self.data = self.nodeValue = data
|
self.data = self.nodeValue = data
|
||||||
|
|
||||||
def writexml(self, writer, indent="", addindent="", newl=""):
|
def writexml(self, writer, indent="", addindent="", newl=""):
|
||||||
|
if "--" in self.data:
|
||||||
|
raise ValueError("'--' is not allowed in a comment node")
|
||||||
writer.write("%s<!--%s-->%s" % (indent, self.data, newl))
|
writer.write("%s<!--%s-->%s" % (indent, self.data, newl))
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -59,6 +59,9 @@ Extension Modules
|
||||||
Library
|
Library
|
||||||
-------
|
-------
|
||||||
|
|
||||||
|
- Issue #1390: Raise ValueError in toxml when an invalid comment would
|
||||||
|
otherwise be produced.
|
||||||
|
|
||||||
- Issue #2914: TimedRotatingFileHandler now takes an optional keyword
|
- Issue #2914: TimedRotatingFileHandler now takes an optional keyword
|
||||||
argument "utc" to use UTC time rather than local time.
|
argument "utc" to use UTC time rather than local time.
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue