From 5329a55bfd2b00d617a40d587cd37050d964ccbf Mon Sep 17 00:00:00 2001 From: jvoisin Date: Sat, 12 Dec 2020 18:57:48 +0000 Subject: Mark the relevant php8 tests as broken (#359) * Skip tests broken on php8 * Oops * Fix some tests * Add some XXE tests for php8 * Fix a test --- src/tests/xxe/disable_xxe_xml_parse_php8.phpt | 106 ++++++++++++++++++++++++++ 1 file changed, 106 insertions(+) create mode 100644 src/tests/xxe/disable_xxe_xml_parse_php8.phpt (limited to 'src/tests/xxe/disable_xxe_xml_parse_php8.phpt') diff --git a/src/tests/xxe/disable_xxe_xml_parse_php8.phpt b/src/tests/xxe/disable_xxe_xml_parse_php8.phpt new file mode 100644 index 0000000..4a8622a --- /dev/null +++ b/src/tests/xxe/disable_xxe_xml_parse_php8.phpt @@ -0,0 +1,106 @@ +--TEST-- +Disable XXE in xml_parse, in php8 +--SKIPIF-- + + +--EXTENSIONS-- +xml +--INI-- +sp.configuration_file={PWD}/config/disable_xxe.ini +--FILE-- + + +]> +&foo; +EOD; + +file_put_contents('content.xml', $xml); + +function create_parser() { + $parser = xml_parser_create(); + xml_set_element_handler( + $parser, + function($parser, $name, array $attributes) { + var_dump($name); + echo "\n"; + var_dump($attributes); + }, + function($parser, $name) { + var_dump($name); + } + ); + + xml_set_character_data_handler( + $parser, + function ($parser, $text){ + echo 'text' . $text; + } + ); + + return $parser; +} + +libxml_disable_entity_loader(true); +$parser = create_parser(); +$doc = xml_parse($parser, $xml, true); +xml_parser_free($parser); + +libxml_disable_entity_loader(false); +$parser = create_parser(); +$doc = xml_parse($parser, $xml, true); +xml_parser_free($parser); + +$xml = "foo"; +file_put_contents('content.xml', $xml); +$parser = create_parser(); +$doc = xml_parse($parser, $xml, true); +xml_parser_free($parser); + +--EXPECTF-- + Deprecated: Function libxml_disable_entity_loader() is deprecated in %s/tests/xxe/disable_xxe_xml_parse.php on line 41 +string(4) "TEST" + +array(0) { +} +string(7) "TESTING" + +array(0) { +} +string(7) "TESTING" +string(4) "TEST" + +Deprecated: Function libxml_disable_entity_loader() is deprecated in %s/tests/xxe/disable_xxe_xml_parse.php on line 46 +string(4) "TEST" + +array(0) { +} +string(7) "TESTING" + +array(0) { +} +string(7) "TESTING" +string(4) "TEST" +string(4) "TEST" + +array(0) { +} +string(7) "TESTING" + +array(0) { +} +textfoostring(7) "TESTING" + -- cgit v1.3