summaryrefslogtreecommitdiff
path: root/src/tests/disable_xxe_dom_disabled.phpt
diff options
context:
space:
mode:
authorjvoisin2019-01-14 19:29:25 +0000
committerGitHub2019-01-14 19:29:25 +0000
commite79f7e3bd992c7f0915ef9afe7afb6d79740527a (patch)
treef881c25694eb00da2331a9ab280ec1c24a5662ab /src/tests/disable_xxe_dom_disabled.phpt
parentc943db586ac46b686b49bdf61d8473e39dd93000 (diff)
Reorganize the testsuite
Splitting the testsuite in several components makes it easier to manage and comprehend. This was also needed some some tests aren't passing on Alpine Linux, but we still want to run as many of them as we can on this platform.
Diffstat (limited to 'src/tests/disable_xxe_dom_disabled.phpt')
-rw-r--r--src/tests/disable_xxe_dom_disabled.phpt55
1 files changed, 0 insertions, 55 deletions
diff --git a/src/tests/disable_xxe_dom_disabled.phpt b/src/tests/disable_xxe_dom_disabled.phpt
deleted file mode 100644
index a791ebc..0000000
--- a/src/tests/disable_xxe_dom_disabled.phpt
+++ /dev/null
@@ -1,55 +0,0 @@
1--TEST--
2Disable XXE
3--SKIPIF--
4<?php
5 if (!extension_loaded("snuffleupagus")) echo "skip";
6 if (!extension_loaded("dom")) echo "skip";
7 ?>
8--INI--
9sp.configuration_file={PWD}/config/disable_xxe_disable.ini
10--FILE--
11<?php
12$dir = __DIR__;
13$content = '<content>WARNING, external entity loaded!</content>';
14file_put_contents($dir . '/content.txt', $content);
15
16$xml = <<<EOD
17<?xml version="1.0"?>
18<!DOCTYPE root
19[
20<!ENTITY foo SYSTEM "file://$dir/content.txt">
21]>
22<test><testing>&foo;</testing></test>
23EOD;
24
25file_put_contents($dir . '/content.xml', $xml);
26
27libxml_disable_entity_loader(true);
28$dom = new DOMDocument('1.0');
29$dom->loadXML($xml, LIBXML_DTDATTR|LIBXML_DTDLOAD|LIBXML_NOENT);
30printf("libxml_disable_entity to true: %s\n", $dom->getElementsByTagName('testing')->item(0)->nodeValue);
31
32libxml_disable_entity_loader(false);
33$dom = new DOMDocument('1.0');
34$dom->loadXML($xml, LIBXML_DTDATTR|LIBXML_DTDLOAD|LIBXML_NOENT);
35printf("libxml_disable_entity to false: %s\n", $dom->getElementsByTagName('testing')->item(0)->nodeValue);
36
37$xml = "<test><testing>foo</testing></test>";
38file_put_contents('content.xml', $xml);
39
40libxml_disable_entity_loader(false);
41$dom = new DOMDocument('1.0');
42$dom->loadXML($xml, LIBXML_DTDATTR|LIBXML_DTDLOAD|LIBXML_NOENT);
43printf("without xxe: %s", $dom->getElementsByTagName('testing')->item(0)->nodeValue);
44
45?>
46--EXPECTF--
47libxml_disable_entity to true: WARNING, external entity loaded!
48libxml_disable_entity to false: WARNING, external entity loaded!
49without xxe: foo
50--CLEAN--
51<?php
52$dir = __DIR__;
53unlink($dir . "/content.xml");
54unlink($dir . "/content.txt");
55?>