#49731 [Opn]: Illegal XML characters allowed (or not turned into entities) in text nodes.

From: Date: Thu, 01 Oct 2009 06:51:01 +0000
Subject: #49731 [Opn]: Illegal XML characters allowed (or not turned into entities) in text nodes.
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-143102@lists.php.net to get a copy of this message
ID: 49731 User updated by: moltendorf at gmail dot com Reported By: moltendorf at gmail dot com Status: Open Bug Type: DOM XML related PHP Version: 5.2.11 New Comment: Adding illegal characters to a text node when saved as XML are not stripped. This breaks the XML, causing it to be "not well-formed" when viewed by standards-compliant browsers, like Firefox. Even converting them to NCRs breaks the XML in most browsers. For reference, the NCR of the "illegal character" included in the reproduce code is &#6; Previous Comments: ------------------------------------------------------------------------ [2009-10-01 06:47:18] moltendorf at gmail dot com Description: ------------ Adding illegal characters to a text node when saved as XML are not either converted to NCRs, or stripped. This breaks the XML, causing it to be "not well-formed" when viewed by standards-compliant browsers, like Firefox. Reproduce code: --------------- <?php header ('Content-Type: text/xml'); $document = new DOMDocument ('1.0', 'utf-8'); $element = $document -> createElement ('element'); $text = $document -> createTextNode (''); // Please copy and paste this line directly; it contains special characters that may not display correctly; and are invalid in XML based on the W3C specification. $element -> appendChild ($text); $document -> appendChild ($element); echo $document -> saveXML ( ); Expected result: ---------------- <?xml version="1.0" encoding="utf-8"?> <element/> Actual result: -------------- <?xml version="1.0" encoding="utf-8"?> <element></element> ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=49731&edit=1

« previous php.bugs (#143102) next »