php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #30566 Parsing a document with namespaces gives different result as PHP4
Submitted: 2004-10-26 17:52 UTC Modified: 2004-11-21 10:59 UTC
From: joern_h at gmx dot net Assigned:
Status: Closed Package: XML related
PHP Version: 5.0.2 OS: Win 2000
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.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: joern_h at gmx dot net
New email:
PHP Version: OS:

 

 [2004-10-26 17:52 UTC] joern_h at gmx dot net
Description:
------------
When parsing a document with multiple / default namespaces a wrong namespace can be reported. PHP 4.3.8 shows the right result.

Reproduce code:
---------------
<?php

error_reporting(E_ALL);

$xml = <<<HEREDOC
<?xml version="1.0"?>
<x xmlns="http://x/" xmlns:y="http://y/">
    <y z="z" y:y="y" xmlns="http://a/" />
</x>
HEREDOC;

$p =& xml_parser_create_ns(null, "\n");
$vals  = array();
$index = array();
xml_parser_set_option($p, XML_OPTION_SKIP_WHITE, true);
xml_parser_set_option($p, XML_OPTION_CASE_FOLDING, false);
if (!xml_parse_into_struct($p, $xml , $vals, $index)) {
    echo xml_error_string($p);
}
xml_parser_free($p);

print_r($vals);

?>


Expected result:
----------------
The attribute y:y should be in the http://y/ namespace, this is also the result when using PHP 4.3.8

Actual result:
--------------
With PHP 5.02 the attribute y:y is in the http://a/ namespace. When the z attribute is removed the bug does not occur.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-11-13 15:34 UTC] rrichards@php.net
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 [2004-11-20 16:47 UTC] sebastian@php.net
Does this mean that XML_Transformer's "abuse" of XML Namespaces (using <foo:bar> without declaring foo using xmlns:foo="...") will no longer work as of PHP 5.0.3?
 [2004-11-21 10:59 UTC] rrichards@php.net
Not sure exactly how XML_Transformer is using namespaces, but this shouldnt affect it's "abuse" of XML Namespaces. The change only makes attributes use their correct namespace rather than use the namespace attached to the first attribute in the list for all attributes of an element. If it were to break XML_Transformer, then there is a serious bug in XML_Transformer.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 00:01:28 2024 UTC