|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #71593 XML Parser largely ignoring DOCTYPE declaration
Submitted: 2016-02-15 02:06 UTC Modified: -
From: anrdaemon at freemail dot ru Assigned:
Status: Open Package: XML related
PHP Version: 5.6.18 OS: Windows
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: anrdaemon at freemail dot ru
New email:
PHP Version: OS:


 [2016-02-15 02:06 UTC] anrdaemon at freemail dot ru
The attached short demonstration is only a tip of iceberg.
I'll submit one more bug in this area shortly.

Test script:
$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"?>
  <!ENTITY pic PUBLIC "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".


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2016-07-10 01:44 UTC] jim dot michaels at Jesusnjim dot com
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.
 [2016-07-11 03:38 UTC] anrdaemon at freemail dot ru
This is not the place to discuss standards.
If you have any gripes, direct them at
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Jul 15 22:01:28 2024 UTC