[lxml-dev] Bug with whitespace in namespaces

Christian Zagrodnick cz at gocept.com
Fri Jul 31 07:57:17 CEST 2009


Hoi,

it is possible to create invalid XML with lxml:

>>> import lxml.etree
>>> import lxml.objectify
>>> xml = lxml.objectify.XML('<a/>')
>>> xml.set('{a b}c', 'foo')             # This should fail!
>>> lxml.etree.tostring(xml)
'<a xmlns:ns0="a b" ns0:c="foo"/>'
>>> lxml.objectify.fromstring(lxml.etree.tostring(xml))
Traceback (most recent call last):
  ...
  File "parser.pxi", line 625, in lxml.etree._handleParseResult 
(src/lxml/lxml.etree.c:64741)
  File "parser.pxi", line 565, in lxml.etree._raiseParseError 
(src/lxml/lxml.etree.c:64084)
lxml.etree.XMLSyntaxError: xmlns:ns0: 'a b' is not a valid URI, line 1, 
column 13
>>>


Regards,
-- 
Christian Zagrodnick · cz at gocept.com
gocept gmbh & co. kg · forsterstraße 29 · 06112 halle (saale) · germany
http://gocept.com · tel +49 345 1229889 4 · fax +49 345 1229889 1
Zope and Plone consulting and development




More information about the lxml-dev mailing list