summaryrefslogtreecommitdiff
path: root/src/tests/disable_xxe_dom.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.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.phpt')
-rw-r--r--src/tests/disable_xxe_dom.phpt73
1 files changed, 0 insertions, 73 deletions
diff --git a/src/tests/disable_xxe_dom.phpt b/src/tests/disable_xxe_dom.phpt
deleted file mode 100644
index e1459e3..0000000
--- a/src/tests/disable_xxe_dom.phpt
+++ /dev/null
@@ -1,73 +0,0 @@
1--TEST--
2Disable XXE
3--SKIPIF--
4<?php
5 if (!extension_loaded("snuffleupagus")) {
6 echo "skip";
7} elseif (!extension_loaded("dom")) {
8 echo "skip";
9}
10 ?>
11--INI--
12sp.configuration_file={PWD}/config/disable_xxe.ini
13--FILE--
14<?php
15$dir = __DIR__;
16$content = 'WARNING, external entity loaded!';
17file_put_contents('content.txt', $content);
18
19$xml = <<<EOD
20<?xml version="1.0"?>
21<!DOCTYPE root
22[
23<!ENTITY foo SYSTEM "file://$dir/content.txt">
24]>
25<test><testing>&foo;</testing></test>
26EOD;
27
28file_put_contents('content.xml', $xml);
29
30libxml_disable_entity_loader(true);
31$dom = new DOMDocument('1.0');
32$dom->loadXML($xml, LIBXML_DTDATTR|LIBXML_DTDLOAD|LIBXML_NOENT);
33printf("libxml_disable_entity to true: %s\n", $dom->getElementsByTagName('testing')->item(0)->nodeValue);
34
35libxml_disable_entity_loader(false);
36$dom = new DOMDocument('1.0');
37$dom->loadXML($xml, LIBXML_DTDATTR|LIBXML_DTDLOAD|LIBXML_NOENT);
38printf("libxml_disable_entity to false: %s\n", $dom->getElementsByTagName('testing')->item(0)->nodeValue);
39
40$xml = "<test><testing>foo</testing></test>";
41file_put_contents('content.xml', $xml);
42
43libxml_disable_entity_loader(false);
44$dom = new DOMDocument('1.0');
45$dom->loadXML($xml, LIBXML_DTDATTR|LIBXML_DTDLOAD|LIBXML_NOENT);
46printf("without xxe: %s", $dom->getElementsByTagName('testing')->item(0)->nodeValue);
47
48?>
49--EXPECTF--
50Warning: DOMDocument::loadXML(): I/O warning : failed to load external entity "file://%a/content.txt" in %a/disable_xxe_dom.php on line %d
51
52Warning: DOMDocument::loadXML(): Failure to process entity foo in Entity, line: %d in %a/disable_xxe_dom.php on line %d
53
54Warning: DOMDocument::loadXML(): Entity 'foo' not defined in Entity, line: %d in %a/disable_xxe_dom.php on line %d
55
56Notice: Trying to get property %a in %a/disable_xxe_dom.php on line %d
57libxml_disable_entity to true:
58
59Warning: DOMDocument::loadXML(): I/O warning : failed to load external entity "file://%a/content.txt" in %a/disable_xxe_dom.php on line %d
60
61Warning: DOMDocument::loadXML(): Failure to process entity foo in Entity, line: %d in %a/disable_xxe_dom.php on line %d
62
63Warning: DOMDocument::loadXML(): Entity 'foo' not defined in Entity, line: %d in %a/disable_xxe_dom.php on line %d
64
65Notice: Trying to get property %a in %a/disable_xxe_dom.php on line %d
66libxml_disable_entity to false:
67without xxe: foo
68--CLEAN--
69<?php
70$dir = __DIR__;
71unlink($dir . "content.xml");
72unlink($dir . "content.txt");
73?>