Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ext/xml/compat.c
Original file line number Diff line number Diff line change
Expand Up @@ -504,10 +504,10 @@ XML_GetErrorCode(XML_Parser parser)

static const XML_Char *const error_mapping[] = {
(const XML_Char *)"No error",
(const XML_Char *)"Internal error",
(const XML_Char *)"No memory",
(const XML_Char *)"Invalid document start",
(const XML_Char *)"Empty document",
(const XML_Char *)"Not well-formed (invalid token)",
(const XML_Char *)"Invalid document end",
(const XML_Char *)"Invalid hexadecimal character reference",
(const XML_Char *)"Invalid decimal character reference",
Expand Down
28 changes: 28 additions & 0 deletions ext/xml/tests/xml_error_string_libxml_codes.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
--TEST--
xml_error_string() maps libxml error codes 1 to 5 to the matching messages
--EXTENSIONS--
xml
--SKIPIF--
<?php
require __DIR__ . '/libxml_expat_skipif.inc';
skipif(want_expat: false);
?>
--FILE--
<?php
$parser = xml_parser_create();
xml_parse($parser, '', true);
$code = xml_get_error_code($parser);
var_dump($code, xml_error_string($code));

for ($code = 1; $code <= 5; $code++) {
var_dump(xml_error_string($code));
}
?>
--EXPECT--
int(4)
string(14) "Empty document"
string(14) "Internal error"
string(9) "No memory"
string(22) "Invalid document start"
string(14) "Empty document"
string(20) "Invalid document end"
Loading