From:             douglas dot wright at pre-school dot org dot uk
Operating system: Windows 7
PHP version:      5.5.0RC1
Package:          DOM XML related
Bug Type:         Bug
Bug description:Elements with values of empty string are turned into void 
elements

Description:
------------
There is a regression in PHP5.5RC where empty text nodes seem to be lost
e.g. <script src=""></script> is turned into <script src=""/>

This breaks XHTML pages because browsers don't recognise the self-closing
syntax.

In PHP 5.3 and 5.4 the two calls below had different output

$doc->createElement('script') output <script/>
$doc->createElement('script', '') output <script></script>

In PHP5.5, they both output <script/> only. Documents parsed using loadXML
suffer this too - <script></script> loses the inner text node and is
transformed into <script/>.

Test script:
---------------
<?php
error_reporting(E_ALL | E_STRICT);
ini_set('display_errors', 1);

$doc = new DOMDocument;
$script = $doc->createElement('script', '');
$script->setAttribute('src', 'foo.js');
$doc->appendChild($script);
echo $doc->saveXML();

$doc->loadXML('<script src="abc.js"></script>');
echo $doc->saveXML();

Expected result:
----------------
<?xml version="1.0"?>
<script src="foo.js"></script>
<?xml version="1.0"?>
<script src="foo.js"></script>

Actual result:
--------------
<?xml version="1.0"?>
<script src="foo.js"/>
<?xml version="1.0"?>
<script src="foo.js"/>

-- 
Edit bug report at https://bugs.php.net/bug.php?id=64899&edit=1
-- 
Try a snapshot (PHP 5.4):   
https://bugs.php.net/fix.php?id=64899&r=trysnapshot54
Try a snapshot (PHP 5.3):   
https://bugs.php.net/fix.php?id=64899&r=trysnapshot53
Try a snapshot (trunk):     
https://bugs.php.net/fix.php?id=64899&r=trysnapshottrunk
Fixed in SVN:               https://bugs.php.net/fix.php?id=64899&r=fixed
Fixed in release:           https://bugs.php.net/fix.php?id=64899&r=alreadyfixed
Need backtrace:             https://bugs.php.net/fix.php?id=64899&r=needtrace
Need Reproduce Script:      https://bugs.php.net/fix.php?id=64899&r=needscript
Try newer version:          https://bugs.php.net/fix.php?id=64899&r=oldversion
Not developer issue:        https://bugs.php.net/fix.php?id=64899&r=support
Expected behavior:          https://bugs.php.net/fix.php?id=64899&r=notwrong
Not enough info:            
https://bugs.php.net/fix.php?id=64899&r=notenoughinfo
Submitted twice:            
https://bugs.php.net/fix.php?id=64899&r=submittedtwice
register_globals:           https://bugs.php.net/fix.php?id=64899&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=64899&r=php4
Daylight Savings:           https://bugs.php.net/fix.php?id=64899&r=dst
IIS Stability:              https://bugs.php.net/fix.php?id=64899&r=isapi
Install GNU Sed:            https://bugs.php.net/fix.php?id=64899&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=64899&r=float
No Zend Extensions:         https://bugs.php.net/fix.php?id=64899&r=nozend
MySQL Configuration Error:  https://bugs.php.net/fix.php?id=64899&r=mysqlcfg

Reply via email to