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