php.net |  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 Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: anrdaemon at freemail dot ru
New email:
PHP Version: OS:

 

 [2016-02-15 02:06 UTC] 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".

Patches

Pull Requests

History

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 https://www.w3.org/TR/REC-xml/#sec-prolog-dtd
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 17:01:58 2024 UTC