[Python-checkins] cpython (merge 3.4 -> default): Merge: #12220: improve minidom error when URI contains spaces.
r.david.murray
python-checkins at python.org
Sun Apr 20 06:48:42 CEST 2014
http://hg.python.org/cpython/rev/3e67d923a0df
changeset: 90421:3e67d923a0df
parent: 90419:004fe3449193
parent: 90420:13c1c5e3d2ee
user: R David Murray <rdmurray at bitdance.com>
date: Sun Apr 20 00:48:25 2014 -0400
summary:
Merge: #12220: improve minidom error when URI contains spaces.
files:
Lib/test/test_minidom.py | 4 ++++
Lib/xml/dom/expatbuilder.py | 4 +++-
Misc/ACKS | 1 +
Misc/NEWS | 3 +++
4 files changed, 11 insertions(+), 1 deletions(-)
diff --git a/Lib/test/test_minidom.py b/Lib/test/test_minidom.py
--- a/Lib/test/test_minidom.py
+++ b/Lib/test/test_minidom.py
@@ -1518,6 +1518,10 @@
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
--- a/Lib/xml/dom/expatbuilder.py
+++ b/Lib/xml/dom/expatbuilder.py
@@ -121,10 +121,12 @@
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
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -1257,6 +1257,7 @@
Anthony Starks
Oliver Steele
Greg Stein
+Marek Stepniowski
Baruch Sterin
Chris Stern
Alex Stewart
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -54,6 +54,9 @@
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.
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list