[php-src] Issue #21486: Dom\HTMLDocument parser mangles xml:space attribute

[email protected] (JKingweb)
Newsgroups php.bugs
Message-ID <[email protected]>
Issue: https://github.com/php/php-src/issues/21486
Author: JKingweb

### Description

The following code:

```php
<?php
$d = @\Dom\HTMLDocument::createFromString("<div></div>");
$e = $d->getElementsByTagName("div")[0];
$e->innerHTML = '<svg xml:space="default" xlink:href="about:blank" xmlns:foo="barspace"></svg>';
$svg = $d->querySelector("svg");
echo $e->innerHTML."\n";
echo $svg->attributes[0]->localName." ".var_export($svg->attributes[0]->namespaceURI, true)."\n";
```

Resulted in this output:
```
<svg space="default" xlink:href="about:blank" xmlns:foo="barspace"></svg>
space NULL
```

But I expected this output instead:
```
<svg xml:space="default" xlink:href="about:blank" xmlns:foo="barspace"></svg>
space 'http://www.w3.org/XML/1998/namespace'
```

Note this case is covered by the test suite here:
https://github.com/html5lib/html5lib-tests/blob/8f43b7ec8c9d02179f5f38e0ea08cb5000fb9c9e/tree-construction/webkit02.dat#L363



### PHP Version

```plain
PHP 8.5.4 (cli) (built: Mar 11 2026 12:09:53) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.5.4, Copyright (c) Zend Technologies
    with Zend OPcache v8.5.4, Copyright (c), by Zend Technologies
```

### Operating System

Arch Linux
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.