[php-src] PR #20453: Fix GH-20439: xml_set_default_handler() does not properly handle special characters in attributes when passing data to callback
| From: | ndossche | Date: | Tue, 11 Nov 2025 12:37:38 +0000 |
| Subject: | [php-src] PR #20453: Fix GH-20439: xml_set_default_handler() does not properly handle special characters in attributes when passing data to callback | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-34008@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/20453
Author: ndossche
We would need to escape the attributes, but there's no builtin method that we can call in
libxml2 to do so in a way consistent with the attribute escape rules and expat.
In fact, expat just repeats the input, while we reconstruct it. To fix the issue, and fix
consistency with expat, we repeat the input as well. This works by seeking to the start and end of
the tag and passing it to the default handler. This is fine for the parser because the parser used
in ext/xml is always in non-progressive mode, so we have access to the entire input buffer.
A nice side effect is that this PR reduces the amount of code in the compatibility layer nicely.