From: webmaster at bison-soft dot de Operating system: linux 2.4 PHP version: 5.1.4 PHP Bug Type: DOM XML related Bug description: DOM fragments ignore document encoding
Description: ------------ An XML-String appended to a DOMDocumentFragment with appendXML() must always be encoded with UTF-8, regardless of the choosen DOMDocument encoding. Even worse, after appending the fragment to the document, the charset in the fragment remains UTF-8, which leads to a DOMDocument with mixed encodings inside. Reproduce code: --------------- $dom = new DOMDocument('1.0','ISO-8859-1'); $dom->loadXML('<parent />'); $frag = $dom->createDocumentFragment(); $frag->appendXML('<child>öäü</child>'); $dom->documentElement->appendChild($frag); Expected result: ---------------- the ISO-8859-1 encoded XML-String will cleanly import into the document fragment. Actual result: -------------- Error: DOMDocumentFragment::appendXML() Entity: line 1: parser error : Input is not proper UTF-8, indicate encoding !! When trying to use an XML-declaration containing the ISO-8859-1 encoding in the child-XML-String: Entity: line 1: parser error : XML declaration allowed only at the start of the document When you convert the child-XML-String to utf8 and append it, you have a DOMDocument with mixed charset -- Edit bug report at http://bugs.php.net/?id=38483&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=38483&r=trysnapshot44 Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=38483&r=trysnapshot52 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=38483&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=38483&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=38483&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=38483&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=38483&r=needscript Try newer version: http://bugs.php.net/fix.php?id=38483&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=38483&r=support Expected behavior: http://bugs.php.net/fix.php?id=38483&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=38483&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=38483&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=38483&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=38483&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=38483&r=dst IIS Stability: http://bugs.php.net/fix.php?id=38483&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=38483&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=38483&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=38483&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=38483&r=mysqlcfg