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

From: Date: Thu, 01 Oct 2009 06:47:19 +0000
Subject: #49731 [NEW]: Illegal XML characters allowed (or not turned into entities) in text nodes.
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-143101@lists.php.net to get a copy of this message
From:             moltendorf at gmail dot com
Operating system: 
PHP version:      5.2.11
PHP Bug Type:     DOM XML related
Bug description:  Illegal XML characters allowed (or not turned into entities) in text nodes.

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 bug report at http://bugs.php.net/?id=49731&edit=1
-- 
Try a snapshot (PHP 5.2):            http://bugs.php.net/fix.php?id=49731&r=trysnapshot52
Try a snapshot (PHP 5.3):            http://bugs.php.net/fix.php?id=49731&r=trysnapshot53
Try a snapshot (PHP 6.0):            http://bugs.php.net/fix.php?id=49731&r=trysnapshot60
Fixed in SVN:                        http://bugs.php.net/fix.php?id=49731&r=fixed
Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=49731&r=needdocs
Fixed in release:                    http://bugs.php.net/fix.php?id=49731&r=alreadyfixed
Need backtrace:                      http://bugs.php.net/fix.php?id=49731&r=needtrace
Need Reproduce Script:               http://bugs.php.net/fix.php?id=49731&r=needscript
Try newer version:                   http://bugs.php.net/fix.php?id=49731&r=oldversion
Not developer issue:                 http://bugs.php.net/fix.php?id=49731&r=support
Expected behavior:                   http://bugs.php.net/fix.php?id=49731&r=notwrong
Not enough info:                     http://bugs.php.net/fix.php?id=49731&r=notenoughinfo
Submitted twice:                     http://bugs.php.net/fix.php?id=49731&r=submittedtwice
register_globals:                    http://bugs.php.net/fix.php?id=49731&r=globals
PHP 4 support discontinued:          http://bugs.php.net/fix.php?id=49731&r=php4
Daylight Savings:                    http://bugs.php.net/fix.php?id=49731&r=dst
IIS Stability:                       http://bugs.php.net/fix.php?id=49731&r=isapi
Install GNU Sed:                     http://bugs.php.net/fix.php?id=49731&r=gnused
Floating point limitations:          http://bugs.php.net/fix.php?id=49731&r=float
No Zend Extensions:                  http://bugs.php.net/fix.php?id=49731&r=nozend
MySQL Configuration Error:           http://bugs.php.net/fix.php?id=49731&r=mysqlcfg



Thread (5 messages)

« previous php.bugs (#143101) next »