#36795 [NEW]: Inappropriate "unterminated entity reference" in DOMElement->setAttribute
From: john at carney dot id dot au
Operating system: Windows/Linux
PHP version: 5.1.2
PHP Bug Type: DOM XML related
Bug description: Inappropriate "unterminated entity reference" in
DOMElement->setAttribute
Description:
------------
While it is not specifically mentioned in the documentation,
DOMElement->setAttribute automatically escapes XML special characters in
the value parameter. Yet, as of PHP 5.1.2 it will throw an "unterminated
entity reference" warning if the supplied value contains an ampersand -
even if it is escaped.
As well as fixing the actual bug, the documentation needs to clarify
*exactly* how special characters in the inputs to this and other DOM
functions are treated. If you are going to silently escape input text, you
need to tell people so that they don't end up with stuff being
double-escaped.
Reproduce code:
---------------
$element->setAttribute ("anattr", "jack & jill") ;
$element->setAttribute ("anattr", "jack & jill") ;
Expected result:
----------------
No warnings should be thrown.
Actual result:
--------------
BOTH calls to setAttribute throw an "unterminated entity reference"
warning.
--
Edit bug report at http://bugs.php.net/?id=36795&edit=1
--
Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=36795&r=trysnapshot44
Try a CVS snapshot (PHP 5.1): http://bugs.php.net/fix.php?id=36795&r=trysnapshot51
Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=36795&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=36795&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=36795&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=36795&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=36795&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=36795&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=36795&r=support
Expected behavior: http://bugs.php.net/fix.php?id=36795&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=36795&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=36795&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=36795&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=36795&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=36795&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=36795&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=36795&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=36795&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=36795&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=36795&r=mysqlcfg
Thread (19 messages)
- john at carney dot id dot au
- rrichards@php.net#36795 [Opn->Fbk]: Inappropriate "unterminated entity reference" in DOMElement->setAttribute
- tamit at xmission dot com#36795 [Com]: Inappropriate "unterminated entity reference" in DOMElement->setAttribute
- php dot net at jax dot be#36795 [Com]: Inappropriate "unterminated entity reference" in DOMElement->setAttribute
- philippe dot levan_nospam at kitpages dot fr#36795 [Com]: Inappropriate "unterminated entity reference" in DOMElement->setAttribute
- ocus51 at gail dot com#36795 [Com]: Inappropriate "unterminated entity reference" in DOMElement->setAttribute
- oscar at cdcovers dot to#36795 [Com]: Inappropriate "unterminated entity reference" in DOMElement->setAttribute
- moshe at varien dot com#36795 [Com]: Inappropriate "unterminated entity reference" in DOMElement->setAttribute
- rob at electronicinsight dot com#36795 [Com]: Inappropriate "unterminated entity reference" in DOMElement->setAttribute
- gary dot malcolm at gmail dot com#36795 [Com]: Inappropriate "unterminated entity reference" in DOMElement->setAttribute
- nforbes@php.net#36795 [NoF->Opn]: Inappropriate "unterminated entity reference" in DOMElement->setAttribute
- jalday at delivery dot com#36795 [Com]: Inappropriate "unterminated entity reference" in DOMElement->setAttribute
- rrichards@php.netBug #36795 [Opn->Bgs]: Inappropriate "unterminated entity reference" in DOMElement->setAttribute
- steven at navolutions dot comBug #36795 [Com]: Inappropriate "unterminated entity reference" in DOMElement->setAttribute
- jan-bugreport at gmx dot deBug #36795 [Com]: Inappropriate "unterminated entity reference" in DOMElement->setAttribute
- abxccd at msn dot comBug #36795 [Com]: Inappropriate "unterminated entity reference" in DOMElement->setAttribute
- matteosistisette at gmail dot comBug #36795 [Com]: Inappropriate "unterminated entity reference" in DOMElement->setAttribute
- hanskrentel at yahoo dot deBug #36795 [Com]: Inappropriate "unterminated entity reference" in DOMElement->setAttribute
- justgig8 at gmail dot comBug #36795 [Com]: Inappropriate "unterminated entity reference" in DOMElement->setAttribute