diff options
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 | ?> | ||
