bug71592.phpt 666 B

12345678910111213141516171819202122232425262728
  1. --TEST--
  2. Bug #71592 (External entity processing never fails)
  3. --EXTENSIONS--
  4. xml
  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>
  18. XML;
  19. $parser = xml_parser_create_ns('UTF-8');
  20. xml_set_external_entity_ref_handler($parser, function () {
  21. return false;
  22. });
  23. xml_parse($parser, $xml);
  24. var_dump(xml_get_error_code($parser) === XML_ERROR_EXTERNAL_ENTITY_HANDLING);
  25. ?>
  26. --EXPECT--
  27. bool(true)