You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
xml.dom.minidom does not validate namespaces #156665
xml.dom.minidom implements the namespace methods of DOM Level 2, but never raises NamespaceErr:
>>> doc.createElementNS(None, "p:e") # a prefix without a namespace
>>> doc.createElementNS("http://x", "xml:e") # the xml prefix in other namespace
>>> doc.createElementNS("http://x", "p:p:e") # a malformed qualified name
>>> doc.createAttributeNS("http://x", "xmlns") # xmlns in other namespace
>>> elem.setAttributeNS(None, "p:a", "v")
All these cases are required to raise NAMESPACE_ERR by DOM Level 2 Core and by the "validate and extract" algorithm of the WHATWG DOM Standard, which adds one more case: a name in the XMLNS namespace which is not xmlns.
The same checks are already implemented in DOMImplementation.createDocument() and createDocumentType(), they are only missing in the factory methods of Document and Element.
Also, prefix is writable and not validated (elem.prefix = "q:r" is accepted, as is the xml prefix in other namespace). Note that in the WHATWG DOM Standard prefix is read-only.
Activity
Merge branch 'main' into pythongh-156665-namespace-validation
gh-156665: Validate namespaces in xml.dom.minidom (GH-156666)
pythongh-156665: Validate namespaces in xml.dom.minidom (pythonGH-156666