Browse Source

#12220: improve minidom error when URI contains spaces.

Fix by 'amathew', test by Marek Stepniowski.
pull/224/head
R David Murray 12 years ago
parent
commit
9077d24d7f
  1. 4
      Lib/test/test_minidom.py
  2. 4
      Lib/xml/dom/expatbuilder.py
  3. 1
      Misc/ACKS
  4. 3
      Misc/NEWS

4
Lib/test/test_minidom.py

@ -1518,6 +1518,10 @@ class MinidomTest(unittest.TestCase):
doc2 = parseString(doc.toxml())
self.confirm(doc2.namespaceURI == xml.dom.EMPTY_NAMESPACE)
def testExceptionOnSpacesInXMLNSValue(self):
with self.assertRaisesRegex(ValueError, 'Unsupported syntax'):
parseString('<element xmlns:abc="http:abc.com/de f g/hi/j k"><abc:foo /></element>')
def testDocRemoveChild(self):
doc = parse(tstfile)
title_tag = doc.documentElement.getElementsByTagName("TITLE")[0]

4
Lib/xml/dom/expatbuilder.py

@ -121,10 +121,12 @@ def _parse_ns_name(builder, name):
qname = "%s:%s" % (prefix, localname)
qname = intern(qname, qname)
localname = intern(localname, localname)
else:
elif len(parts) == 2:
uri, localname = parts
prefix = EMPTY_PREFIX
qname = localname = intern(localname, localname)
else:
raise ValueError("Unsupported syntax: spaces in URIs not supported: %r" % name)
return intern(uri, uri), localname, prefix, qname

1
Misc/ACKS

@ -1255,6 +1255,7 @@ Joel Stanley
Anthony Starks
Oliver Steele
Greg Stein
Marek Stepniowski
Baruch Sterin
Chris Stern
Alex Stewart

3
Misc/NEWS

@ -39,6 +39,9 @@ Core and Builtins
Library
-------
- Issue #12220: mindom now raises a custom ValueError indicating it doesn't
support spaces in URIs instead of letting a 'split' ValueError bubble up.
- Issue #21239: patch.stopall() didn't work deterministically when the same
name was patched more than once.

Loading…
Cancel
Save