summaryrefslogtreecommitdiff
path: root/src/tests/xxe/disable_xxe_dom_disabled_php8.phpt
diff options
context:
space:
mode:
authorjvoisin2020-12-12 18:57:48 +0000
committerjvoisin2020-12-12 20:33:14 +0100
commit5329a55bfd2b00d617a40d587cd37050d964ccbf (patch)
tree81ba53c4f950442a904a437458228d1ab2859227 /src/tests/xxe/disable_xxe_dom_disabled_php8.phpt
parente34f5f5aaa4a40745bd652198d75b879aa09a53c (diff)
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
Diffstat (limited to 'src/tests/xxe/disable_xxe_dom_disabled_php8.phpt')
-rw-r--r--src/tests/xxe/disable_xxe_dom_disabled_php8.phpt60
1 files changed, 60 insertions, 0 deletions
diff --git a/src/tests/xxe/disable_xxe_dom_disabled_php8.phpt b/src/tests/xxe/disable_xxe_dom_disabled_php8.phpt
new file mode 100644
index 0000000..c0db7fc
--- /dev/null
+++ b/src/tests/xxe/disable_xxe_dom_disabled_php8.phpt
@@ -0,0 +1,60 @@
1--TEST--
2Disable XXE in php8
3--SKIPIF--
4<?php if (!extension_loaded("snuffleupagus") || !extension_loaded("dom")) print("skip"); ?>
5<?php if (PHP_VERSION_ID < 80000) print "skip"; ?>
6--INI--
7sp.configuration_file={PWD}/config/disable_xxe_disable.ini
8--EXTENSIONS--
9dom
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--CLEAN--
47<?php
48$dir = __DIR__;
49unlink($dir . "/content.xml");
50unlink($dir . "/content.txt");
51?>
52--EXPECTF--
53Deprecated: Function libxml_disable_entity_loader() is deprecated in %s/tests/xxe/disable_xxe_dom_disabled.php on line %d
54libxml_disable_entity to true: WARNING, external entity loaded!
55
56Deprecated: Function libxml_disable_entity_loader() is deprecated in %s/tests/xxe/disable_xxe_dom_disabled.php on line %d
57libxml_disable_entity to false: WARNING, external entity loaded!
58
59Deprecated: Function libxml_disable_entity_loader() is deprecated in %s/tests/xxe/disable_xxe_dom_disabled.php on line %d
60