summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorR David Murray <rdmurray@bitdance.com>2014-04-20 04:48:25 (GMT)
committerR David Murray <rdmurray@bitdance.com>2014-04-20 04:48:25 (GMT)
commit4eef074e4cb8f3c10000fa2187c7a718a1d76d40 (patch)
treea164fc2fd4fe7d58185fb351167f258f48b7ec60
parent3ff96eb1e4aff841d33e9ccbe9f4278b8786ca84 (diff)
parent9077d24d7f85e09e53def11b2beeaf40749e2464 (diff)
downloadcpython-4eef074e4cb8f3c10000fa2187c7a718a1d76d40.zip
cpython-4eef074e4cb8f3c10000fa2187c7a718a1d76d40.tar.gz
cpython-4eef074e4cb8f3c10000fa2187c7a718a1d76d40.tar.bz2
Merge: #12220: improve minidom error when URI contains spaces.
-rw-r--r--Lib/test/test_minidom.py4
-rw-r--r--Lib/xml/dom/expatbuilder.py4
-rw-r--r--Misc/ACKS1
-rw-r--r--Misc/NEWS3
4 files changed, 11 insertions, 1 deletions
diff --git a/Lib/test/test_minidom.py b/Lib/test/test_minidom.py
index a1516c2..5ab4bfe 100644
--- a/Lib/test/test_minidom.py
+++ b/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]
diff --git a/Lib/xml/dom/expatbuilder.py b/Lib/xml/dom/expatbuilder.py
index 81e2df7..8976144 100644
--- a/Lib/xml/dom/expatbuilder.py
+++ b/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
diff --git a/Misc/ACKS b/Misc/ACKS
index e08bb13..7a37df8 100644
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -1257,6 +1257,7 @@ Joel Stanley
Anthony Starks
Oliver Steele
Greg Stein
+Marek Stepniowski
Baruch Sterin
Chris Stern
Alex Stewart
diff --git a/Misc/NEWS b/Misc/NEWS
index 55a146a..e59ba47 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -54,6 +54,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 #21068: The ssl.PROTOCOL* constants are now enum members.
- Issue #21262: New method assert_not_called for Mock.