summaryrefslogtreecommitdiff
path: root/src/tests/xxe
diff options
context:
space:
mode:
authorBen Fuhrmannek2021-02-16 11:16:59 +0100
committerBen Fuhrmannek2021-02-16 11:16:59 +0100
commit5484bcb5eb2714e7438927e2566c86a74d7c51af (patch)
treeb78326d2999397be4c08e06b23209981f82a4ea9 /src/tests/xxe
parent7ac1e3866ef4f146c6c93a5ca13b9aebb14e936a (diff)
parentcecfdd808da67be908dbe7144cc8c74dfb3f855e (diff)
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'src/tests/xxe')
-rw-r--r--src/tests/xxe/disable_xxe_dom.phpt69
-rw-r--r--src/tests/xxe/disable_xxe_dom_disabled.phpt1
-rw-r--r--src/tests/xxe/disable_xxe_xml_parse.phpt1
3 files changed, 2 insertions, 69 deletions
diff --git a/src/tests/xxe/disable_xxe_dom.phpt b/src/tests/xxe/disable_xxe_dom.phpt
deleted file mode 100644
index 58467f7..0000000
--- a/src/tests/xxe/disable_xxe_dom.phpt
+++ /dev/null
@@ -1,69 +0,0 @@
1--TEST--
2Disable XXE
3--SKIPIF--
4<?php if (!extension_loaded("snuffleupagus") || !extension_loaded("dom")) print("skip"); ?>
5--INI--
6sp.configuration_file={PWD}/config/disable_xxe.ini
7--EXTENSIONS--
8dom
9--FILE--
10<?php
11$dir = __DIR__;
12$content = 'WARNING, external entity loaded!';
13file_put_contents('content.txt', $content);
14
15$xml = <<<EOD
16<?xml version="1.0"?>
17<!DOCTYPE root
18[
19<!ENTITY foo SYSTEM "file://$dir/content.txt">
20]>
21<test><testing>&foo;</testing></test>
22EOD;
23
24file_put_contents('content.xml', $xml);
25
26libxml_disable_entity_loader(true);
27$dom = new DOMDocument('1.0');
28$dom->loadXML($xml, LIBXML_DTDATTR|LIBXML_DTDLOAD|LIBXML_NOENT);
29printf("libxml_disable_entity to true: %s\n", $dom->getElementsByTagName('testing')->item(0)->nodeValue);
30
31libxml_disable_entity_loader(false);
32$dom = new DOMDocument('1.0');
33$dom->loadXML($xml, LIBXML_DTDATTR|LIBXML_DTDLOAD|LIBXML_NOENT);
34printf("libxml_disable_entity to false: %s\n", $dom->getElementsByTagName('testing')->item(0)->nodeValue);
35
36$xml = "<test><testing>foo</testing></test>";
37file_put_contents('content.xml', $xml);
38
39libxml_disable_entity_loader(false);
40$dom = new DOMDocument('1.0');
41$dom->loadXML($xml, LIBXML_DTDATTR|LIBXML_DTDLOAD|LIBXML_NOENT);
42printf("without xxe: %s", $dom->getElementsByTagName('testing')->item(0)->nodeValue);
43
44?>
45--EXPECTF--
46Warning: DOMDocument::loadXML(): I/O warning : failed to load external entity "file://%a/content.txt" in %a/disable_xxe_dom.php on line %d
47
48Warning: DOMDocument::loadXML(): Failure to process entity foo in Entity, line: %d in %a/disable_xxe_dom.php on line %d
49
50Warning: DOMDocument::loadXML(): Entity 'foo' not defined in Entity, line: %d in %a/disable_xxe_dom.php on line %d
51
52Notice: Trying to get property %a in %a/disable_xxe_dom.php on line %d
53libxml_disable_entity to true:
54
55Warning: DOMDocument::loadXML(): I/O warning : failed to load external entity "file://%a/content.txt" in %a/disable_xxe_dom.php on line %d
56
57Warning: DOMDocument::loadXML(): Failure to process entity foo in Entity, line: %d in %a/disable_xxe_dom.php on line %d
58
59Warning: DOMDocument::loadXML(): Entity 'foo' not defined in Entity, line: %d in %a/disable_xxe_dom.php on line %d
60
61Notice: Trying to get property %a in %a/disable_xxe_dom.php on line %d
62libxml_disable_entity to false:
63without xxe: foo
64--CLEAN--
65<?php
66$dir = __DIR__;
67unlink($dir . "content.xml");
68unlink($dir . "content.txt");
69?>
diff --git a/src/tests/xxe/disable_xxe_dom_disabled.phpt b/src/tests/xxe/disable_xxe_dom_disabled.phpt
index fe88d76..493f5a3 100644
--- a/src/tests/xxe/disable_xxe_dom_disabled.phpt
+++ b/src/tests/xxe/disable_xxe_dom_disabled.phpt
@@ -2,6 +2,7 @@
2Disable XXE 2Disable XXE
3--SKIPIF-- 3--SKIPIF--
4<?php if (!extension_loaded("snuffleupagus") || !extension_loaded("dom")) print("skip"); ?> 4<?php if (!extension_loaded("snuffleupagus") || !extension_loaded("dom")) print("skip"); ?>
5<?php if (PHP_VERSION_ID >= 80000) print "skip"; ?>
5--INI-- 6--INI--
6sp.configuration_file={PWD}/config/disable_xxe_disable.ini 7sp.configuration_file={PWD}/config/disable_xxe_disable.ini
7--EXTENSIONS-- 8--EXTENSIONS--
diff --git a/src/tests/xxe/disable_xxe_xml_parse.phpt b/src/tests/xxe/disable_xxe_xml_parse.phpt
index b6dec2d..6b48bea 100644
--- a/src/tests/xxe/disable_xxe_xml_parse.phpt
+++ b/src/tests/xxe/disable_xxe_xml_parse.phpt
@@ -8,6 +8,7 @@ Disable XXE in xml_parse
8 echo "skip because the `xml` extension isn't loaded"; 8 echo "skip because the `xml` extension isn't loaded";
9} 9}
10 ?> 10 ?>
11<?php if (PHP_VERSION_ID >= 80000) print "skip"; ?>
11--EXTENSIONS-- 12--EXTENSIONS--
12xml 13xml
13--INI-- 14--INI--