php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #71594 NS handler is never called for default namespace defined in DOCTYPE
Submitted: 2016-02-15 02:25 UTC Modified: 2018-04-02 20:54 UTC
From: anrdaemon at freemail dot ru Assigned: cmb (profile)
Status: Not a bug 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:25 UTC] anrdaemon at freemail dot ru
Description:
------------
When NS-aware parser is created, the handler set by xml_set_start_namespace_decl_handler() is never called for default namespace given in the DOCTYPE attribute, when the root tag is processed.

See also https://bugs.php.net/bug.php?id=71593

Test script:
---------------
<?php
$indent = '';
$parser = xml_parser_create_ns('UTF-8');

xml_set_start_namespace_decl_handler($parser, function($self, $name, $target)
  {
    global $indent;
    $ns = $name ?: '(default)';
    print $indent . "NS:{$ns} {$target}\n";
  });

// Expecting the notion of NS:(default) when the root tag is processed.
xml_parse($parser, '<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE shape PUBLIC "-//Dia//DTD Dia shape 1.0//EN" "http://www.daa.com.au/~james/dia-shape-ns">
<shape xmlns:svg="http://www.w3.org/2000/svg">
  <name>Custom - Styles mix</name>
</shape>', true);

print xml_error_string(xml_get_error_code($parser)) . "\n";
?>

Expected result:
----------------
NS:(default) http://www.daa.com.au/~james/dia-shape-ns
NS:svg http://www.w3.org/2000/svg
No error

I.e. NS(default) should be printed when root tag is processed (before root element handler is called).

Actual result:
--------------
NS:svg http://www.w3.org/2000/svg
No error

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2018-04-02 12:53 UTC] cmb@php.net
-Status: Open +Status: Not a bug -Assigned To: +Assigned To: cmb
 [2018-04-02 12:53 UTC] cmb@php.net
> Expecting the notion of NS:(default) when the root tag is
> processed.

Why?  In the given XML there is no default namespace declaration,
opposed to something like:

  <foo xmlns="http://example.com"/>

So, in my opinion, this is not a bug.
 [2018-04-02 19:20 UTC] anrdaemon at freemail dot ru
In other words, it does not process doctype declaration.
Got it, thanks.
 [2018-04-02 20:54 UTC] cmb@php.net
> In other words, it does not process doctype declaration.

To my knowledge, a doctype declaration is not a namespace
declaration, nor could it contain one. It seems to me that bug
#71593 is not necessarily related to this issue.
 [2018-04-03 09:17 UTC] anrdaemon at freemail dot ru
Under that light, appears to be so.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Dec 22 09:01:29 2024 UTC