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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
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

Pull Requests

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-2025 The PHP Group
All rights reserved.
Last updated: Wed Feb 05 20:01:30 2025 UTC