#5762: fix handling of empty namespace in minidom, which would result in AttributeError on toxml().
This commit is contained in:
parent
d4460aaacd
commit
b9cd72a9f7
|
@ -1489,6 +1489,13 @@ class MinidomTest(unittest.TestCase):
|
|||
doc.appendChild(doc.createComment("foo--bar"))
|
||||
self.assertRaises(ValueError, doc.toxml)
|
||||
|
||||
def testEmptyXMLNSValue(self):
|
||||
doc = parseString("<element xmlns=''>\n"
|
||||
"<foo/>\n</element>")
|
||||
doc2 = parseString(doc.toxml())
|
||||
self.confirm(doc2.namespaceURI == xml.dom.EMPTY_NAMESPACE)
|
||||
|
||||
|
||||
def test_main():
|
||||
run_unittest(MinidomTest)
|
||||
|
||||
|
|
|
@ -301,9 +301,10 @@ def _in_document(node):
|
|||
|
||||
def _write_data(writer, data):
|
||||
"Writes datachars to writer."
|
||||
data = data.replace("&", "&").replace("<", "<")
|
||||
data = data.replace("\"", """).replace(">", ">")
|
||||
writer.write(data)
|
||||
if data:
|
||||
data = data.replace("&", "&").replace("<", "<"). \
|
||||
replace("\"", """).replace(">", ">")
|
||||
writer.write(data)
|
||||
|
||||
def _get_elements_by_tagName_helper(parent, name, rc):
|
||||
for node in parent.childNodes:
|
||||
|
|
|
@ -24,6 +24,9 @@ Core and Builtins
|
|||
Library
|
||||
-------
|
||||
|
||||
- Issue #5762: Fix AttributeError raised by ``xml.dom.minidom`` when an empty
|
||||
XML namespace attribute is encountered.
|
||||
|
||||
- Issue #2830: Add the ``html.escape()`` function, which quotes all problematic
|
||||
characters by default. Deprecate ``cgi.escape()``.
|
||||
|
||||
|
|
Loading…
Reference in New Issue