diff options
Diffstat (limited to 'src/tests/disable_xxe_simplexml_oop.phpt')
| -rw-r--r-- | src/tests/disable_xxe_simplexml_oop.phpt | 51 |
1 files changed, 0 insertions, 51 deletions
diff --git a/src/tests/disable_xxe_simplexml_oop.phpt b/src/tests/disable_xxe_simplexml_oop.phpt deleted file mode 100644 index 43c4fbf..0000000 --- a/src/tests/disable_xxe_simplexml_oop.phpt +++ /dev/null | |||
| @@ -1,51 +0,0 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable XXE | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php | ||
| 5 | if (!extension_loaded("snuffleupagus")) echo "skip"; | ||
| 6 | if (!extension_loaded("simplexml")) echo "skip"; | ||
| 7 | ?> | ||
| 8 | --INI-- | ||
| 9 | sp.configuration_file={PWD}/config/disable_xxe.ini | ||
| 10 | --FILE-- | ||
| 11 | <?php | ||
| 12 | $dir = __DIR__; | ||
| 13 | $content = 'WARNING, external entity loaded!'; | ||
| 14 | file_put_contents('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> | ||
| 23 | EOD; | ||
| 24 | |||
| 25 | file_put_contents('content.xml', $xml); | ||
| 26 | |||
| 27 | libxml_disable_entity_loader(true); | ||
| 28 | $doc = simplexml_load_string($xml); | ||
| 29 | printf("libxml_disable_entity to true: %s\n", $doc->testing); | ||
| 30 | |||
| 31 | libxml_disable_entity_loader(false); | ||
| 32 | $doc = simplexml_load_string($xml); | ||
| 33 | printf("libxml_disable_entity to false: %s\n", $doc->testing); | ||
| 34 | |||
| 35 | $xml = "<test><testing>foo</testing></test>"; | ||
| 36 | file_put_contents('content.xml', $xml); | ||
| 37 | |||
| 38 | $doc = simplexml_load_string($xml); | ||
| 39 | printf("without xxe: %s", $doc->testing); | ||
| 40 | |||
| 41 | ?> | ||
| 42 | --EXPECT-- | ||
| 43 | libxml_disable_entity to true: | ||
| 44 | libxml_disable_entity to false: | ||
| 45 | without xxe: foo | ||
| 46 | --CLEAN-- | ||
| 47 | <?php | ||
| 48 | $dir = __DIR__; | ||
| 49 | unlink($dir . "/content.xml"); | ||
| 50 | unlink($dir . "/content.txt"); | ||
| 51 | ?> | ||
