xref: /PHP-7.4/ext/xml/tests/bug71592.phpt (revision 2816a3fd)
1--TEST--
2Bug #71592 (External entity processing never fails)
3--SKIPIF--
4<?php
5if (!extension_loaded('xml')) die('skip xml extension not available');
6?>
7--FILE--
8<?php
9// The tag mismatch at the end of the XML is on purpose, to make sure that the
10// parser actually stops after the handler returns FALSE.
11$xml = <<<XML
12<?xml version="1.0" encoding="UTF-8"?>
13<!DOCTYPE root [
14  <!ENTITY pic PUBLIC "image.gif" "http://example.org/image.gif">
15]>
16<root>
17<p>&pic;</p>
18<p></nop>
19</root>
20XML;
21
22$parser = xml_parser_create_ns('UTF-8');
23xml_set_external_entity_ref_handler($parser, function () {
24    return false;
25});
26xml_parse($parser, $xml);
27var_dump(xml_get_error_code($parser) === XML_ERROR_EXTERNAL_ENTITY_HANDLING);
28?>
29===DONE===
30--EXPECT--
31bool(true)
32===DONE===
33