Bug #71593 [Com]: XML Parser largely ignoring DOCTYPE declaration
Edit report at https://bugs.php.net/bug.php?id=71593&edit=1
ID: 71593
Comment by: jim dot michaels at Jesusnjim dot com
Reported by: anrdaemon at freemail dot ru
Summary: XML Parser largely ignoring DOCTYPE declaration
Status: Open
Type: Bug
Package: XML related
Operating System: Windows
PHP Version: 5.6.18
Block user comment: N
Private report: N
New Comment:
you should note that (if this applies to you):
<!DOCTYPE ...>
<?xml ...?>
I question the properness of the <!DOCTYPE's end not having a / but this is a w3 issue.
Previous Comments:
------------------------------------------------------------------------
[2016-02-15 02:06:28] anrdaemon at freemail dot ru
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 this bug report at https://bugs.php.net/bug.php?id=71593&edit=1
Thread (3 messages)