ID: 36795 Comment by: php dot net at jax dot be Reported By: john at carney dot id dot au Status: No Feedback Bug Type: DOM XML related Operating System: Windows/Linux PHP Version: 5.1.2 New Comment:
In PHP 4.2.2 I have the same issue. <code> <?php require_once("sms/messageRelay.class.php"); $doc = domxml_new_doc("1.0"); $msg = $doc->create_element("message"); $msg->set_attribute("type", "MT"); $doc->append_child($msg); $auth = $doc->create_element("authentication"); $str = "abc < d & e > f"; $auth->set_content($str); $msg->append_child($auth); echo "<pre>"; echo $doc->dump_mem(true, "UTF-8"); echo "</pre>"; ?> </code> It chokes on the &. Previous Comments: ------------------------------------------------------------------------ [2006-04-01 04:49:32] tamit at xmission dot com This is most definitely a bug. I've replicated by producing the following tree in my code: (This is well-formed XML so I have no idea why there would be a problem.) ---------BEGIN XML---------------------------- <?xml version="1.0" encoding="iso-8859-1"?> <classes> <class classid="0" parentid="" class_level="0">Root<class classid="1" parentid="0" class_level="1">Adhesives </class> <class classid="3286" parentid="0" class_level="1">Agricultural and Farming Products</class> <class classid="3283" parentid="0" class_level="1">Architectural and Civil Engineering Products</class> <class classid="14" parentid="0" class_level="1">Automatic ID</class> <class classid="45" parentid="0" class_level="1">Chemical Processing </class> <class classid="124" parentid="0" class_level="1">Cleaning Products </class> <class classid="148" parentid="0" class_level="1">Communication Systems </class> <class classid="264" parentid="0" class_level="1">Computer Hardware </class> <class classid="3281" parentid="0" class_level="1">Construction Equipment and Supplies</class> <class classid="489" parentid="0" class_level="1">Controls </class> <class classid="589" parentid="0" class_level="1">Display </class> <class classid="612" parentid="0" class_level="1">Electrical Equipment </class> <class classid="772" parentid="0" class_level="1">Electronic Components </class> <class classid="3282" parentid="0" class_level="1">Explosives, Armaments, and Weaponry</class> <class classid="920" parentid="0" class_level="1">Fasteners </class> <class classid="954" parentid="0" class_level="1">Fluid </class> <class classid="3461" parentid="0" class_level="1">Food Processing </class> <class classid="3288" parentid="0" class_level="1">Health, Medical, </class> <class classid="1029" parentid="0" class_level="1">HVAC</class> <class classid="1068" parentid="0" class_level="1">Labels Tags Signage </class> <class classid="3279" parentid="0" class_level="1">Laboratory and Research Supplies and Equipment</class> <class classid="1083" parentid="0" class_level="1">Lubricants</class> <class classid="1106" parentid="0" class_level="1">Machinery </class> <class classid="1424" parentid="0" class_level="1">Material Handling </class> <class classid="1303" parentid="0" class_level="1">Materials </class> <class classid="3284" parentid="0" class_level="1">Mechanical Components and Assemblies</class> <class classid="1620" parentid="0" class_level="1">Mechanical Power Transmission</class> <class classid="3462" parentid="0" class_level="1">Mining, Oil Drilling </class> <class classid="1728" parentid="0" class_level="1">Mounting </class> <class classid="3285" parentid="0" class_level="1">Non-Industrial Products</class> <class classid="1782" parentid="0" class_level="1">Optics </class> <class classid="2054" parentid="0" class_level="1">Packaging Equipment </class> <class classid="2151" parentid="0" class_level="1">Paints </class> <class classid="2185" parentid="0" class_level="1">Plant Furnishings </class> <class classid="2196" parentid="0" class_level="1">Portable Tools</class> <class classid="2286" parentid="0" class_level="1">Printing </class> <class classid="3539" parentid="0" class_level="1">Problematic Headings</class> <class classid="3463" parentid="0" class_level="1">Retail and Sales Equipment</class> <class classid="2328" parentid="0" class_level="1">Robotics</class> <class classid="2369" parentid="0" class_level="1">Safety </class> <class classid="2399" parentid="0" class_level="1">Sensors Monitors </class> <class classid="3280" parentid="0" class_level="1">Services</class> <class classid="2585" parentid="0" class_level="1">Software</class> <class classid="2697" parentid="0" class_level="1">Test </class> <class classid="3919" parentid="0" class_level="1">Textile Industry Products</class> <class classid="3167" parentid="0" class_level="1">Thermal </class> <class classid="3190" parentid="0" class_level="1">Timers </class> <class classid="3287" parentid="0" class_level="1">Transportation Industry Products</class> <class classid="3193" parentid="0" class_level="1">Vision Systems</class> <class classid="3208" parentid="0" class_level="1">Waste Handling Equipment</class> <class classid="3246" parentid="0" class_level="1">Welding Equipment </class> </class> </classes> --------------END XML--------------------------- ------------------------------------------------------------------------ [2006-03-28 01:00:05] php-bugs at lists dot php dot net No feedback was provided for this bug for over a week, so it is being suspended automatically. If you are able to provide the information that was originally requested, please do so and change the status of the bug back to "Open". ------------------------------------------------------------------------ [2006-03-20 15:34:55] [EMAIL PROTECTED] Thank you for this bug report. To properly diagnose the problem, we need a short but complete example script to be able to reproduce this bug ourselves. A proper reproducing script starts with <?php and ends with ?>, is max. 10-20 lines long and does not require any external resources such as databases, etc. If possible, make the script source available online and provide an URL to it here. Try to avoid embedding huge scripts into the report. Also, what version of libxml2 are you using as I am unable to reproduce this. ------------------------------------------------------------------------ [2006-03-20 02:05:23] john at carney dot id dot au 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 this bug report at http://bugs.php.net/?id=36795&edit=1