[php-src] PR #11528: Fix GH-11500: Namespace reuse in createElementNS() generates wrong output
| From: | nielsdos | Date: | Sun, 25 Jun 2023 12:26:04 +0000 |
| Subject: | [php-src] PR #11528: Fix GH-11500: Namespace reuse in createElementNS() generates wrong output | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-22811@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/11528
Author: nielsdos
When you construct a DOM tree containing subtrees which are constructed top-down, this won't
remove the redundant namespaces. That's because the following conditions hold:
1) The namespace are reused from the doc->oldNs list.
2) Therefore during reconciliation no nsDef field is set, so no redundant
namespaces are removed by our reconciliation code.
Furthermore, it would only be fixed up automatically if the tree wasn't added in bottom-up way,
or if it had been constructed bottom-up from the start.
Fix it by setting a flag to remove redundant namespaces in the libxml2 reconciliation call.
Since removing redundant namespaces may have a performance cost, we only do this after performing a
simple check.
Closes GH-11500