diff options
| author | jvoisin | 2019-01-14 19:29:25 +0000 |
|---|---|---|
| committer | GitHub | 2019-01-14 19:29:25 +0000 |
| commit | e79f7e3bd992c7f0915ef9afe7afb6d79740527a (patch) | |
| tree | f881c25694eb00da2331a9ab280ec1c24a5662ab /src/tests/disable_xxe_dom.phpt | |
| parent | c943db586ac46b686b49bdf61d8473e39dd93000 (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.phpt | 73 |
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-- | ||
| 2 | Disable 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-- | ||
| 12 | sp.configuration_file={PWD}/config/disable_xxe.ini | ||
| 13 | --FILE-- | ||
| 14 | <?php | ||
| 15 | $dir = __DIR__; | ||
| 16 | $content = 'WARNING, external entity loaded!'; | ||
| 17 | file_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> | ||
| 26 | EOD; | ||
| 27 | |||
| 28 | file_put_contents('content.xml', $xml); | ||
| 29 | |||
| 30 | libxml_disable_entity_loader(true); | ||
| 31 | $dom = new DOMDocument('1.0'); | ||
| 32 | $dom->loadXML($xml, LIBXML_DTDATTR|LIBXML_DTDLOAD|LIBXML_NOENT); | ||
| 33 | printf("libxml_disable_entity to true: %s\n", $dom->getElementsByTagName('testing')->item(0)->nodeValue); | ||
| 34 | |||
| 35 | libxml_disable_entity_loader(false); | ||
| 36 | $dom = new DOMDocument('1.0'); | ||
| 37 | $dom->loadXML($xml, LIBXML_DTDATTR|LIBXML_DTDLOAD|LIBXML_NOENT); | ||
| 38 | printf("libxml_disable_entity to false: %s\n", $dom->getElementsByTagName('testing')->item(0)->nodeValue); | ||
| 39 | |||
| 40 | $xml = "<test><testing>foo</testing></test>"; | ||
| 41 | file_put_contents('content.xml', $xml); | ||
| 42 | |||
| 43 | libxml_disable_entity_loader(false); | ||
| 44 | $dom = new DOMDocument('1.0'); | ||
| 45 | $dom->loadXML($xml, LIBXML_DTDATTR|LIBXML_DTDLOAD|LIBXML_NOENT); | ||
| 46 | printf("without xxe: %s", $dom->getElementsByTagName('testing')->item(0)->nodeValue); | ||
| 47 | |||
| 48 | ?> | ||
| 49 | --EXPECTF-- | ||
| 50 | Warning: DOMDocument::loadXML(): I/O warning : failed to load external entity "file://%a/content.txt" in %a/disable_xxe_dom.php on line %d | ||
| 51 | |||
| 52 | Warning: DOMDocument::loadXML(): Failure to process entity foo in Entity, line: %d in %a/disable_xxe_dom.php on line %d | ||
| 53 | |||
| 54 | Warning: DOMDocument::loadXML(): Entity 'foo' not defined in Entity, line: %d in %a/disable_xxe_dom.php on line %d | ||
| 55 | |||
| 56 | Notice: Trying to get property %a in %a/disable_xxe_dom.php on line %d | ||
| 57 | libxml_disable_entity to true: | ||
| 58 | |||
| 59 | Warning: DOMDocument::loadXML(): I/O warning : failed to load external entity "file://%a/content.txt" in %a/disable_xxe_dom.php on line %d | ||
| 60 | |||
| 61 | Warning: DOMDocument::loadXML(): Failure to process entity foo in Entity, line: %d in %a/disable_xxe_dom.php on line %d | ||
| 62 | |||
| 63 | Warning: DOMDocument::loadXML(): Entity 'foo' not defined in Entity, line: %d in %a/disable_xxe_dom.php on line %d | ||
| 64 | |||
| 65 | Notice: Trying to get property %a in %a/disable_xxe_dom.php on line %d | ||
| 66 | libxml_disable_entity to false: | ||
| 67 | without xxe: foo | ||
| 68 | --CLEAN-- | ||
| 69 | <?php | ||
| 70 | $dir = __DIR__; | ||
| 71 | unlink($dir . "content.xml"); | ||
| 72 | unlink($dir . "content.txt"); | ||
| 73 | ?> | ||
