summaryrefslogtreecommitdiff
path: root/src/tests/xxe/disable_xxe_xml_parse_php8.phpt
diff options
context:
space:
mode:
Diffstat (limited to 'src/tests/xxe/disable_xxe_xml_parse_php8.phpt')
-rw-r--r--src/tests/xxe/disable_xxe_xml_parse_php8.phpt106
1 files changed, 0 insertions, 106 deletions
diff --git a/src/tests/xxe/disable_xxe_xml_parse_php8.phpt b/src/tests/xxe/disable_xxe_xml_parse_php8.phpt
deleted file mode 100644
index 4a8622a..0000000
--- a/src/tests/xxe/disable_xxe_xml_parse_php8.phpt
+++ /dev/null
@@ -1,106 +0,0 @@
1--TEST--
2Disable XXE in xml_parse, in php8
3--SKIPIF--
4<?php
5 if (!extension_loaded("snuffleupagus")) {
6 echo "skip because snuffleupagus isn't loaded";
7} elseif (!extension_loaded("xml")) {
8 echo "skip because the `xml` extension isn't loaded";
9}
10?>
11<?php if (PHP_VERSION_ID < 80000) print "skip"; ?>
12--EXTENSIONS--
13xml
14--INI--
15sp.configuration_file={PWD}/config/disable_xxe.ini
16--FILE--
17<?php
18$dir = __DIR__;
19$content = 'WARNING, external entity loaded!';
20file_put_contents('content.txt', $content);
21
22$xml = <<<EOD
23<?xml version="1.0"?>
24<!DOCTYPE root
25[
26<!ENTITY foo SYSTEM "file://$dir/content.txt">
27]>
28<test><testing>&foo;</testing></test>
29EOD;
30
31file_put_contents('content.xml', $xml);
32
33function create_parser() {
34 $parser = xml_parser_create();
35 xml_set_element_handler(
36 $parser,
37 function($parser, $name, array $attributes) {
38 var_dump($name);
39 echo "\n";
40 var_dump($attributes);
41 },
42 function($parser, $name) {
43 var_dump($name);
44 }
45 );
46
47 xml_set_character_data_handler(
48 $parser,
49 function ($parser, $text){
50 echo 'text' . $text;
51 }
52 );
53
54 return $parser;
55}
56
57libxml_disable_entity_loader(true);
58$parser = create_parser();
59$doc = xml_parse($parser, $xml, true);
60xml_parser_free($parser);
61
62libxml_disable_entity_loader(false);
63$parser = create_parser();
64$doc = xml_parse($parser, $xml, true);
65xml_parser_free($parser);
66
67$xml = "<test><testing>foo</testing></test>";
68file_put_contents('content.xml', $xml);
69$parser = create_parser();
70$doc = xml_parse($parser, $xml, true);
71xml_parser_free($parser);
72
73--EXPECTF--
74 Deprecated: Function libxml_disable_entity_loader() is deprecated in %s/tests/xxe/disable_xxe_xml_parse.php on line 41
75string(4) "TEST"
76
77array(0) {
78}
79string(7) "TESTING"
80
81array(0) {
82}
83string(7) "TESTING"
84string(4) "TEST"
85
86Deprecated: Function libxml_disable_entity_loader() is deprecated in %s/tests/xxe/disable_xxe_xml_parse.php on line 46
87string(4) "TEST"
88
89array(0) {
90}
91string(7) "TESTING"
92
93array(0) {
94}
95string(7) "TESTING"
96string(4) "TEST"
97string(4) "TEST"
98
99array(0) {
100}
101string(7) "TESTING"
102
103array(0) {
104}
105textfoostring(7) "TESTING"
106