[php-src] Issue #12870: Creating an xmlns attribute results in a DOMException

From: Date: Tue, 05 Dec 2023 05:10:42 +0000
Subject: [php-src] Issue #12870: Creating an xmlns attribute results in a DOMException
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-245977@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/12870 Author: dustinwilson ### Description The following code: ```php <?php $d = new \DOMDocument(); $d->appendChild($d->createElement('root')); $d->createAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns'); ``` Resulted in this output: ``` PHP Fatal error: Uncaught DOMException: Namespace Error ``` But I expected this output instead: N/A The first step of the [DOM specification for createElementNS](https://dom.spec.whatwg.org/#dom-document-createattributens) is: > 1. Let namespace, prefix, and localName be the result of passing namespace and qualifiedName to > [validate and extract](https://dom.spec.whatwg.org/#validate-and-extract). The validate and extract section has the following steps: > 6. If prefix is non-null and namespace is null, then > [throw](https://webidl.spec.whatwg.org/#dfn-throw) a > "[NamespaceError](https://webidl.spec.whatwg.org/#namespaceerror)" > [DOMException](https://webidl.spec.whatwg.org/#idl-DOMException). > 7. If prefix is "xml" and namespace is not the [XML > namespace](https://infra.spec.whatwg.org/#xml-namespace), then > [throw](https://webidl.spec.whatwg.org/#dfn-throw) a > "[NamespaceError](https://webidl.spec.whatwg.org/#namespaceerror)" > [DOMException](https://webidl.spec.whatwg.org/#idl-DOMException). > 8. If either qualifiedName or prefix is "xmlns" and namespace is not the [XMLNS > namespace](https://infra.spec.whatwg.org/#xmlns-namespace), then > [throw](https://webidl.spec.whatwg.org/#dfn-throw) a > "[NamespaceError](https://webidl.spec.whatwg.org/#namespaceerror)" > [DOMException](https://webidl.spec.whatwg.org/#idl-DOMException). > 9. If namespace is the [XMLNS namespace](https://infra.spec.whatwg.org/#xmlns-namespace) and > neither qualifiedName nor prefix is "xmlns", then > [throw](https://webidl.spec.whatwg.org/#dfn-throw) a > "[NamespaceError](https://webidl.spec.whatwg.org/#namespaceerror)" > [DOMException](https://webidl.spec.whatwg.org/#idl-DOMException). The namespace is the XMLNS namespace, and the qualifiedName is "xmlns", so it shouldn't be throwing a DOMException. PHP 8.2.x doesn't throw the DOMException. My system has libxml 2.12.1. ### PHP Version PHP 8.3.0 ### Operating System macOS 13.4.1

« previous php.bugs (#245977) next »