Bug #71593 [NEW]: XML Parser largely ignoring DOCTYPE declaration

From: Date: Mon, 15 Feb 2016 02:06:30 +0000
Subject: Bug #71593 [NEW]: XML Parser largely ignoring DOCTYPE declaration
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-199212@lists.php.net to get a copy of this message
From: anrdaemon at freemail dot ru Operating system: Windows PHP version: 5.6.18 Package: XML related Bug Type: Bug Bug description:XML Parser largely ignoring DOCTYPE declaration Description: ------------ The attached short demonstration is only a tip of iceberg. I'll submit one more bug in this area shortly. Test script: --------------- <?php $indent = ''; $parser = xml_parser_create_ns('UTF-8'); xml_set_element_handler($parser, function($self, $name, $attributes){ global $indent; print "{$indent}{$name} " . json_encode($attributes, 832) . "\n"; $indent .= "\t"; }, function($self, $name){ global $indent; $indent = substr($indent, 0, -1); print "{$indent}/{$name}\n"; }); xml_set_character_data_handler($parser, function($self, $data){ global $indent; if($text = trim($data)) print "{$indent}#text: {$text}\n"; }); xml_parse($parser, '<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE x [ <!ENTITY pic PUBLIC "image.gif" "http://example.org/image.gif"> ]> <p>&pic;</p>', true); // Expecting at least 'Undeclared entity error' (entity was declared for a different root tag). print xml_error_string(xml_get_error_code($parser)) . "\n"; ?> Expected result: ---------------- I would expect "Undeclared entity error" at the very least. Optimally "Mismatched tag" (wrong root tag). Actual result: -------------- "No error". -- Edit bug report at https://bugs.php.net/bug.php?id=71593&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=71593&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=71593&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=71593&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=71593&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=71593&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=71593&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=71593&r=needscript Try newer version: https://bugs.php.net/fix.php?id=71593&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=71593&r=support Expected behavior: https://bugs.php.net/fix.php?id=71593&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=71593&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=71593&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=71593&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=71593&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=71593&r=dst IIS Stability: https://bugs.php.net/fix.php?id=71593&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=71593&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=71593&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=71593&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=71593&r=mysqlcfg

« previous php.bugs (#199212) next »