Index: /trunk/twisted/topfiles/4503.bugfix
===================================================================
--- /trunk/twisted/topfiles/4503.bugfix (revision 29852)
+++ /trunk/twisted/topfiles/4503.bugfix (revision 29852)
@@ -0,0 +1,1 @@
+twisted.words.xish.domish now correctly parses XML with namespaces which include whitespace.
Index: /trunk/twisted/words/test/test_domish.py
===================================================================
--- /trunk/twisted/words/test/test_domish.py (revision 25184)
+++ /trunk/twisted/words/test/test_domish.py (revision 29852)
@@ -1,3 +1,3 @@
-# Copyright (c) 2001-2008 Twisted Matrix Laboratories.
+# Copyright (c) 2001-2010 Twisted Matrix Laboratories.
# See LICENSE for details.
@@ -199,4 +199,17 @@
self.assertEquals(self.elements[0].child2.uri, '')
+
+ def test_namespaceWithWhitespace(self):
+ """
+ Whitespace in an xmlns value is preserved in the resulting node's C{uri}
+ attribute.
+ """
+ xml = ""
+ self.stream.parse(xml)
+ self.assertEquals(self.elements[0].uri, " bar baz ")
+ self.assertEquals(
+ self.elements[0].attributes, {(" bar baz ", "baz"): "quux"})
+
+
def testChildPrefix(self):
xml = ""
Index: /trunk/twisted/words/xish/domish.py
===================================================================
--- /trunk/twisted/words/xish/domish.py (revision 25184)
+++ /trunk/twisted/words/xish/domish.py (revision 29852)
@@ -1,5 +1,4 @@
# -*- test-case-name: twisted.words.test.test_domish -*-
-#
-# Copyright (c) 2001-2007 Twisted Matrix Laboratories.
+# Copyright (c) 2001-2010 Twisted Matrix Laboratories.
# See LICENSE for details.
@@ -72,5 +71,4 @@
# Further optimizations
- parent = elem.parent
name = elem.name
uri = elem.uri
@@ -759,6 +757,8 @@
def _onStartElement(self, name, attrs):
- # Generate a qname tuple from the provided name
- qname = name.split(" ")
+ # Generate a qname tuple from the provided name. See
+ # http://docs.python.org/library/pyexpat.html#xml.parsers.expat.ParserCreate
+ # for an explanation of the formatting of name.
+ qname = name.rsplit(" ", 1)
if len(qname) == 1:
qname = ('', name)
@@ -766,6 +766,6 @@
# Process attributes
for k, v in attrs.items():
- if k.find(" ") != -1:
- aqname = k.split(" ")
+ if " " in k:
+ aqname = k.rsplit(" ", 1)
attrs[(aqname[0], aqname[1])] = v
del attrs[k]