php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #36116 setAttribute() allows colon in attribute name
Submitted: 2006-01-21 18:30 UTC Modified: 2006-01-23 20:21 UTC
From: info at intelligentstreaming dot com Assigned:
Status: Not a bug Package: DOM XML related
PHP Version: 5.1.2 OS: Linux
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: info at intelligentstreaming dot com
New email:
PHP Version: OS:

 

 [2006-01-21 18:30 UTC] info at intelligentstreaming dot com
Description:
------------
DOMElement::setAttribute() allows one to specify a colon in the attribute name, for example "xsi:type". If an attribute with a matching namespace prefix and local name already exists in the element, the creation of the new attribute will cause two identically-named attributes to exist in the same element.


Reproduce code:
---------------
$dom = DOMDocument::loadXML("<root xmlns:somens='uri://bla'><element somens:foo='bar' /></root>");

print $dom->firstChild->firstChild->setAttribute('somens:foo', 'baz');

print $dom->saveXML();

Expected result:
----------------
DOMElement::setAttribute() should return FALSE or throw an exception; the DOMDocument should not be changed.


Actual result:
--------------
<?xml version="1.0"?>
<root xmlns:somens="uri://bla"><element somens:foo="bar" somens:foo="baz"/></root>


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-01-23 20:21 UTC] rrichards@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

you are mixing DOM level 1 functionality with namespaced document. DOM specs will tell you that results will be unexpected when doing this.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri May 03 13:01:32 2024 UTC