mirror of
https://github.com/php/php-src.git
synced 2025-08-16 05:58:45 +02:00
Merge branch 'PHP-8.2'
* PHP-8.2: Fix GH-11160: Few tests failed building with new libxml 2.11.0
This commit is contained in:
commit
82b05373b1
10 changed files with 178 additions and 2 deletions
34
ext/dom/tests/DOMDocument_loadXML_error2_gte2_11.phpt
Normal file
34
ext/dom/tests/DOMDocument_loadXML_error2_gte2_11.phpt
Normal file
|
@ -0,0 +1,34 @@
|
|||
--TEST--
|
||||
Test DOMDocument::loadXML() detects not-well formed XML
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (LIBXML_VERSION < 21100) die('skip libxml2 test variant for version >= 2.11');
|
||||
?>
|
||||
--DESCRIPTION--
|
||||
This test verifies the method detects attributes values not closed between " or '
|
||||
Environment variables used in the test:
|
||||
- XML_FILE: the xml file to load
|
||||
- LOAD_OPTIONS: the second parameter to pass to the method
|
||||
- EXPECTED_RESULT: the expected result
|
||||
--CREDITS--
|
||||
Antonio Diaz Ruiz <dejalatele@gmail.com>
|
||||
--INI--
|
||||
assert.bail=true
|
||||
--EXTENSIONS--
|
||||
dom
|
||||
--ENV--
|
||||
XML_FILE=/not_well_formed2.xml
|
||||
LOAD_OPTIONS=0
|
||||
EXPECTED_RESULT=0
|
||||
--FILE_EXTERNAL--
|
||||
domdocumentloadxml_test_method.inc
|
||||
--EXPECTF--
|
||||
Warning: DOMDocument::loadXML(): AttValue: " or ' expected in Entity, line: 4 in %s on line %d
|
||||
|
||||
Warning: DOMDocument::loadXML(): internal error: xmlParseStartTag: problem parsing attributes in Entity, line: 4 in %s on line %d
|
||||
|
||||
Warning: DOMDocument::loadXML(): Couldn't find end of Start Tag book line 4 in Entity, line: 4 in %s on line %d
|
||||
|
||||
Warning: DOMDocument::loadXML(): Opening and ending tag mismatch: books line 3 and book in Entity, line: 7 in %s on line %d
|
||||
|
||||
Warning: DOMDocument::loadXML(): Extra content at the end of the document in Entity, line: 8 in %s on line %d
|
|
@ -1,5 +1,9 @@
|
|||
--TEST--
|
||||
Test DOMDocument::loadXML() detects not-well formed XML
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (LIBXML_VERSION >= 21100) die('skip libxml2 test variant for version < 2.11');
|
||||
?>
|
||||
--DESCRIPTION--
|
||||
This test verifies the method detects attributes values not closed between " or '
|
||||
Environment variables used in the test:
|
34
ext/dom/tests/DOMDocument_load_error2_gte2_11.phpt
Normal file
34
ext/dom/tests/DOMDocument_load_error2_gte2_11.phpt
Normal file
|
@ -0,0 +1,34 @@
|
|||
--TEST--
|
||||
Test DOMDocument::load() detects not-well formed
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (LIBXML_VERSION < 21100) die('skip libxml2 test variant for version >= 2.11');
|
||||
?>
|
||||
--DESCRIPTION--
|
||||
This test verifies the method detects attributes values not closed between " or '
|
||||
Environment variables used in the test:
|
||||
- XML_FILE: the xml file to load
|
||||
- LOAD_OPTIONS: the second parameter to pass to the method
|
||||
- EXPECTED_RESULT: the expected result
|
||||
--CREDITS--
|
||||
Antonio Diaz Ruiz <dejalatele@gmail.com>
|
||||
--INI--
|
||||
assert.bail=true
|
||||
--EXTENSIONS--
|
||||
dom
|
||||
--ENV--
|
||||
XML_FILE=/not_well_formed2.xml
|
||||
LOAD_OPTIONS=0
|
||||
EXPECTED_RESULT=0
|
||||
--FILE_EXTERNAL--
|
||||
domdocumentload_test_method.inc
|
||||
--EXPECTF--
|
||||
Warning: DOMDocument::load(): AttValue: " or ' expected in %s on line %d
|
||||
|
||||
Warning: DOMDocument::load(): internal error: xmlParseStartTag: problem parsing attributes in %s on line %d
|
||||
|
||||
Warning: DOMDocument::load(): Couldn't find end of Start Tag book line 4 in %s on line %d
|
||||
|
||||
Warning: DOMDocument::load(): Opening and ending tag mismatch: books line 3 and book in %s on line %d
|
||||
|
||||
Warning: DOMDocument::load(): Extra content at the end of the document in %s on line %d
|
|
@ -1,5 +1,9 @@
|
|||
--TEST--
|
||||
Test DOMDocument::load() detects not-well formed XML
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (LIBXML_VERSION >= 21100) die('skip libxml2 test variant for version < 2.11');
|
||||
?>
|
||||
--DESCRIPTION--
|
||||
This test verifies the method detects attributes values not closed between " or '
|
||||
Environment variables used in the test:
|
|
@ -514,6 +514,8 @@ static void php_libxml_ctx_error_level(int level, void *ctx, const char *msg)
|
|||
} else {
|
||||
php_error_docref(NULL, level, "%s in Entity, line: %d", msg, parser->input->line);
|
||||
}
|
||||
} else {
|
||||
php_error_docref(NULL, E_WARNING, "%s", msg);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -58,6 +58,6 @@ bool(true)
|
|||
int(4)
|
||||
bool(true)
|
||||
|
||||
Warning: DOMDocument::loadXML(): I/O warning : failed to load external entity "file:///%s/test_bug_61367-read/bad" in %s on line %d
|
||||
Warning: DOMDocument::loadXML(): %Sfailed to load external entity "file:///%s/test_bug_61367-read/bad" in %s on line %d
|
||||
|
||||
Warning: Attempt to read property "nodeValue" on null in %s on line %d
|
||||
|
|
|
@ -39,6 +39,6 @@ bool(true)
|
|||
Deprecated: Function libxml_disable_entity_loader() is deprecated in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: DOMDocument::loadXML(): I/O warning : failed to load external entity "%s" in %s on line %d
|
||||
Warning: DOMDocument::loadXML(): %Sfailed to load external entity "%s" in %s on line %d
|
||||
bool(true)
|
||||
Done
|
||||
|
|
|
@ -39,6 +39,8 @@ echo "Done.\n";
|
|||
string(10) "-//FOO/BAR"
|
||||
string(%d) "%sfoobar.dtd"
|
||||
|
||||
Warning: DOMDocument::validate(): Failed to load external entity "-//FOO/BAR" in %s on line %d
|
||||
|
||||
Warning: DOMDocument::validate(): Could not load the external subset "foobar.dtd" in %s on line %d
|
||||
bool(false)
|
||||
bool(true)
|
||||
|
|
95
ext/xml/tests/bug26614_libxml_gte2_11.phpt
Normal file
95
ext/xml/tests/bug26614_libxml_gte2_11.phpt
Normal file
|
@ -0,0 +1,95 @@
|
|||
--TEST--
|
||||
Bug #26614 (CDATA sections skipped on line count)
|
||||
--EXTENSIONS--
|
||||
xml
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!defined("LIBXML_VERSION")) die('skip libxml2 test');
|
||||
if (LIBXML_VERSION < 21100) die('skip libxml2 test variant for version >= 2.11');
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
/*
|
||||
this test works fine with Expat but fails with libxml
|
||||
which we now use as default
|
||||
|
||||
further investigation has shown that not only line count
|
||||
is skipped on CDATA sections but that libxml does also
|
||||
show different column numbers and byte positions depending
|
||||
on context and in opposition to what one would expect to
|
||||
see and what good old Expat reported just fine ...
|
||||
*/
|
||||
|
||||
$xmls = array();
|
||||
|
||||
// Case 1: CDATA Sections
|
||||
$xmls["CDATA"] ='<?xml version="1.0" encoding="iso-8859-1" ?>
|
||||
<data>
|
||||
<![CDATA[
|
||||
multi
|
||||
line
|
||||
CDATA
|
||||
block
|
||||
]]>
|
||||
</data>';
|
||||
|
||||
// Case 2: replace some characters so that we get comments instead
|
||||
$xmls["Comment"] ='<?xml version="1.0" encoding="iso-8859-1" ?>
|
||||
<data>
|
||||
<!-- ATA[
|
||||
multi
|
||||
line
|
||||
CDATA
|
||||
block
|
||||
-->
|
||||
</data>';
|
||||
|
||||
// Case 3: replace even more characters so that only textual data is left
|
||||
$xmls["Text"] ='<?xml version="1.0" encoding="iso-8859-1" ?>
|
||||
<data>
|
||||
-!-- ATA[
|
||||
multi
|
||||
line
|
||||
CDATA
|
||||
block
|
||||
---
|
||||
</data>';
|
||||
|
||||
function startElement($parser, $name, $attrs) {
|
||||
printf("<$name> at line %d, col %d (byte %d)\n",
|
||||
xml_get_current_line_number($parser),
|
||||
xml_get_current_column_number($parser),
|
||||
xml_get_current_byte_index($parser));
|
||||
}
|
||||
|
||||
function endElement($parser, $name) {
|
||||
printf("</$name> at line %d, col %d (byte %d)\n",
|
||||
xml_get_current_line_number($parser),
|
||||
xml_get_current_column_number($parser),
|
||||
xml_get_current_byte_index($parser));
|
||||
}
|
||||
|
||||
function characterData($parser, $data) {
|
||||
// dummy
|
||||
}
|
||||
|
||||
foreach ($xmls as $desc => $xml) {
|
||||
echo "$desc\n";
|
||||
$xml_parser = xml_parser_create();
|
||||
xml_set_element_handler($xml_parser, "startElement", "endElement");
|
||||
xml_set_character_data_handler($xml_parser, "characterData");
|
||||
if (!xml_parse($xml_parser, $xml, true))
|
||||
echo "Error: ".xml_error_string(xml_get_error_code($xml_parser))."\n";
|
||||
xml_parser_free($xml_parser);
|
||||
}
|
||||
?>
|
||||
--EXPECTF--
|
||||
CDATA
|
||||
<DATA> at line 2, col %d (byte 50)
|
||||
</DATA> at line 9, col %d (byte 96)
|
||||
Comment
|
||||
<DATA> at line 2, col %d (byte 50)
|
||||
</DATA> at line 9, col %d (byte 96)
|
||||
Text
|
||||
<DATA> at line 2, col %d (byte 50)
|
||||
</DATA> at line 9, col %d (byte 96)
|
|
@ -5,6 +5,7 @@ xml
|
|||
--SKIPIF--
|
||||
<?php
|
||||
if (!defined("LIBXML_VERSION")) die('skip libxml2 test');
|
||||
if (LIBXML_VERSION >= 21100) die('skip libxml2 test variant for version < 2.11');
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
Loading…
Add table
Add a link
Reference in a new issue