[php-src] PR #25843: Fix libxml error messages for codes 1 to 4 in xml_error_string()
| From: | lacatoire | Date: | Fri, 27 Nov 2026 15:45:03 +0000 |
| Subject: | [php-src] PR #25843: Fix libxml error messages for codes 1 to 4 in xml_error_string() | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-41125@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/25843
Author: lacatoire
With libxml2, entries 1 to 4 of
error_mapping[] don't match libxml2's error
codes, so an empty document (code 4) is reported as "Not well-formed (invalid token)".
"Internal error" is restored at index 1 and the extra entry at index 4 is removed; codes 5
and above are unchanged.
### To reproduce
```php
<?php
$parser = xml_parser_create();
xml_parse($parser, '', true);
$code = xml_get_error_code($parser);
var_dump($code, xml_error_string($code));
for ($i = 1; $i <= 5; $i++) {
echo $i, ': ', xml_error_string($i), "\n";
}
```
Before (PHP 8.4.28 and 8.5.13, libxml2 2.13.9):
```
int(4)
string(31) "Not well-formed (invalid token)"
1: No memory
2: Invalid document start
3: Empty document
4: Not well-formed (invalid token)
5: Invalid document end
```
After:
```
int(4)
string(14) "Empty document"
1: Internal error
2: No memory
3: Invalid document start
4: Empty document
5: Invalid document end
```