php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #74989 DOMElement::setAttributeNS() should report error when @xml:space = 'foo'
Submitted: 2017-07-25 21:37 UTC Modified: 2017-07-25 21:51 UTC
From: paul at sparrowhawkcomputing dot com Assigned:
Status: Not a bug Package: DOM XML related
PHP Version: 5.6.31 OS: Windows 10 Pro
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: paul at sparrowhawkcomputing dot com
New email:
PHP Version: OS:

 

 [2017-07-25 21:37 UTC] paul at sparrowhawkcomputing dot com
Description:
------------
To conform to the XML spec, DOMElement::setAttributeNS() [and other related methods like DOMDocument::createAttributeNS(), etc] incorrectly allows @xml:space='foo'.

See the related bug (https://bugs.php.net/bug.php?id=74988) for the details on WHY this should not be allowed.



Test script:
---------------
libxml_use_internal_errors( true );
libxml_clear_errors();
$dom = new DOMDocument();
$root = $dom->createElement( 'root' );
$root->setAttributeNS( 'http://www.w3.org/XML/1998/namespace', 'xml:space', 'foo' );
$errs = libxml_get_errors();
$dom->appendChild( $root );
$xml = $dom->saveXML();
var_dump( $errs );
var_dump( $xml );

Expected result:
----------------
Either:

    DOMElement::setAttributeNS() [and other related methods like DOMDocument::createAttributeNS(), etc) should return false and libxml_get_errors() should report the well-formedness error

or

    DOMElement::setAttributeBS() should return true but just ignore setting the attribute and it's value.


Actual result:
--------------
array(0) {
}
string(46) "<?xml version="1.0"?>
<root xml:space="foo"/>
"

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-07-25 21:46 UTC] paul at sparrowhawkcomputing dot com
Oops.  The summary should have been "DOMElement::setAttributeNS() should report error when @xml:space = 'foo'".
 [2017-07-25 21:51 UTC] requinix@php.net
-Status: Open +Status: Not a bug
 [2017-07-25 21:51 UTC] requinix@php.net
Does seem like a bug. But as with your other report, it's an issue in libxml and not PHP.
http://xmlsoft.org/bugs.html
 [2017-07-25 21:51 UTC] requinix@php.net
-Summary: DOMElement::setAttribute() should report error when @xml:space = 'foo' +Summary: DOMElement::setAttributeNS() should report error when @xml:space = 'foo'
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 01:01:28 2024 UTC