php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #48078 SimpleXML allows white spaces as attribute names
Submitted: 2009-04-26 12:18 UTC Modified: 2009-04-26 14:51 UTC
From: ifeghali@php.net Assigned:
Status: Not a bug Package: SimpleXML related
PHP Version: 5.3.0RC1 OS: Mac OS X
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 this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: ifeghali@php.net
New email:
PHP Version: OS:

 

 [2009-04-26 12:18 UTC] ifeghali@php.net
Description:
------------
SimpleXML allows the creation of attributes containing white spaces in the name. This violates the XML specs [1].

* reported by Thiago Toledo during PHP Test Fest 2009 (Rio UG).

[1] http://www.w3.org/TR/2006/REC-xml11-20060816/#NT-NameChar

Reproduce code:
---------------
<?php
    $xmlExample = "<?xml version='1.0' standalone='yes'?><allNodes></allNodes>";
    $myXML = new SimpleXMLElement($xmlExample);
    $myXML->addAttribute('Basic Attribute','Basic Attribute Content');
    echo $myXML->asXML();
?>

Expected result:
----------------
Warning: Wrong character for XML attribute name

Actual result:
--------------
<?xml version="1.0" standalone="yes"?>
<allNodes Basic Attribute="Basic Attribute Content"/>

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-04-26 14:51 UTC] iliaa@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.

I think its more along the lines of a libxml2 bug then PHP's since 
attribute creation is done by simply calling the libxml API. PHP cannot 
perform validation on XML.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed May 01 22:01:31 2024 UTC