php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #31191 "unterminated entity reference" when using the value parameter to createElement
Submitted: 2004-12-20 06:46 UTC Modified: 2004-12-20 08:10 UTC
Votes:31
Avg. Score:4.1 ± 1.0
Reproduced:28 of 28 (100.0%)
Same Version:7 (25.0%)
Same OS:22 (78.6%)
From: php at owenpshaw dot net Assigned:
Status: Wont fix Package: DOM XML related
PHP Version: 5.0.3 OS: Linux
Private report: No CVE-ID:
Have you experienced this issue?
Rate the importance of this bug to you:

 [2004-12-20 06:46 UTC] php at owenpshaw dot net
Description:
------------
It looks like no escaping is done to the optional "value" parameter in the DomDocument::createElement() and DomDocument::createElementNS().  The online documentation doesn't specify what the correct behavior should be, and it's not part of the DOM standard, so it seems possible that this is a bug.
  

Reproduce code:
---------------
$document = new DomDocument();
$element = $document->createElement('foo','&');

Expected result:
----------------
I would expect the '&' (or any other character that should be escaped) to be escaped as if I had used DomDocument::createTextNode().

Actual result:
--------------
Warning: unterminated entity reference in [FILE] on line [LINE]

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-12-20 08:10 UTC] chregu@php.net
We discussed that topic (internally) and we decided not to implement escaping here. If I remember correctly, one of the reason was for backwards compatibility, as we discovered this  after 5.0.0 was released.

Use $doc->createTextNode() if you want to have automatic escaping
 [2010-01-16 22:13 UTC] svn@php.net
Automatic comment from SVN on behalf of bjori
Revision: http://svn.php.net/viewvc/?view=revision&revision=293630
Log: Rephrase after reading bug#31191 (see bug#50742)
 
PHP Copyright © 2001-2014 The PHP Group
All rights reserved.
Last updated: Fri Apr 18 23:01:58 2014 UTC