From 868f96c759b6650d88ff9f4fbc5c048302134248 Mon Sep 17 00:00:00 2001 From: Sebastien Blot Date: Wed, 20 Sep 2017 10:11:01 +0200 Subject: Initial import --- src/tests/disable_xxe_dom.phpt | 71 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 src/tests/disable_xxe_dom.phpt (limited to 'src/tests/disable_xxe_dom.phpt') diff --git a/src/tests/disable_xxe_dom.phpt b/src/tests/disable_xxe_dom.phpt new file mode 100644 index 0000000..47f3db3 --- /dev/null +++ b/src/tests/disable_xxe_dom.phpt @@ -0,0 +1,71 @@ +--TEST-- +Disable XXE +--SKIPIF-- + +--INI-- +extension=`php-config --extension-dir`/dom.so +sp.configuration_file={PWD}/config/disable_xxe.ini +--FILE-- + + +]> +&foo; +EOD; + +file_put_contents('content.xml', $xml); + +libxml_disable_entity_loader(true); +$dom = new DOMDocument('1.0'); +$dom->loadXML($xml, LIBXML_DTDATTR|LIBXML_DTDLOAD|LIBXML_NOENT); +printf("libxml_disable_entity to true: %s\n", $dom->getElementsByTagName('testing')->item(0)->nodeValue); + +libxml_disable_entity_loader(false); +$dom = new DOMDocument('1.0'); +$dom->loadXML($xml, LIBXML_DTDATTR|LIBXML_DTDLOAD|LIBXML_NOENT); +printf("libxml_disable_entity to false: %s\n", $dom->getElementsByTagName('testing')->item(0)->nodeValue); + +$xml = "foo"; +file_put_contents('content.xml', $xml); + +libxml_disable_entity_loader(false); +$dom = new DOMDocument('1.0'); +$dom->loadXML($xml, LIBXML_DTDATTR|LIBXML_DTDLOAD|LIBXML_NOENT); +printf("without xxe: %s", $dom->getElementsByTagName('testing')->item(0)->nodeValue); + +?> +--EXPECTF-- +Warning: DOMDocument::loadXML(): I/O warning : failed to load external entity "file://%a/content.txt" in %a/disable_xxe_dom.php on line %d + +Warning: DOMDocument::loadXML(): Failure to process entity foo in Entity, line: %d in %a/disable_xxe_dom.php on line %d + +Warning: DOMDocument::loadXML(): Entity 'foo' not defined in Entity, line: %d in %a/disable_xxe_dom.php on line %d + +Notice: Trying to get property of non-object in %a/disable_xxe_dom.php on line %d +libxml_disable_entity to true: + +Warning: DOMDocument::loadXML(): I/O warning : failed to load external entity "file://%a/content.txt" in %a/disable_xxe_dom.php on line %d + +Warning: DOMDocument::loadXML(): Failure to process entity foo in Entity, line: %d in %a/disable_xxe_dom.php on line %d + +Warning: DOMDocument::loadXML(): Entity 'foo' not defined in Entity, line: %d in %a/disable_xxe_dom.php on line %d + +Notice: Trying to get property of non-object in %a/disable_xxe_dom.php on line %d +libxml_disable_entity to false: +without xxe: foo +--CLEAN-- + -- cgit v1.3