Bug #74989 [Com]: DOMElement::setAttribute() should report error when @xml:space = 'foo'

From: Date: Tue, 25 Jul 2017 21:46:35 +0000
Subject: Bug #74989 [Com]: DOMElement::setAttribute() should report error when @xml:space = 'foo'
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-210329@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=74989&edit=1 ID: 74989 Comment by: paul at sparrowhawkcomputing dot com Reported by: paul at sparrowhawkcomputing dot com Summary: DOMElement::setAttribute() should report error when @xml:space = 'foo' Status: Open Type: Bug Package: DOM XML related Operating System: Windows 10 Pro PHP Version: 5.6.31 Block user comment: N Private report: N New Comment: Oops. The summary should have been "DOMElement::setAttributeNS() should report error when @xml:space = 'foo'". Previous Comments: ------------------------------------------------------------------------ [2017-07-25 21:37:18] 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"/> " ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=74989&edit=1

« previous php.bugs (#210329) next »