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
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: 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

Pull Requests

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-2025 The PHP Group
All rights reserved.
Last updated: Sat Jul 12 05:01:33 2025 UTC