ID:               49437
 User updated by:  matt at matthewfagan dot com
 Reported By:      matt at matthewfagan dot com
-Status:           Open
+Status:           Closed
 Bug Type:         SimpleXML related
 Operating System: ALL
 PHP Version:      5.2.10
 New Comment:

Scratch this. It seems to be a bug in the underlying libxml (they don't
treat the predefined entities as entities), which also means that all
the PHP functions based on libxml have the same problem.

Still, it might be nice to add a comment to the documentation that the
LIBXML_NOENT option does not apply to built-in XML entities, only to
DTD-defined entities.


Previous Comments:
------------------------------------------------------------------------

[2009-09-02 05:30:07] matt at matthewfagan dot com

Description:
------------
One of the options to simplexml_load_string is LIBXML_NOENT. This
option cannot be turned off.

Reproduce code:
---------------
The prototype for the simplexml_load_string function is:

object simplexml_load_string ( string $data [, string
$class_name="SimpleXMLElement" [, int $options=0 [, string $ns [, bool
$is_prefix=false ]]]] )

Note the "$options=0". However, it actually behaves like
"$options=LIBXML_NOENT". There is no way to disable this behavior.
Explicitly specifying 0 does not turn off LIBXML_NOENT.

Code to reproduce:
echo simplexml_load_string("<data>&amp;</data>", "SimpleXMLElement",
0);

Expected result:
----------------
This should return "&amp;", because I have explicity turned off the
LIBXML_NOENT option. However, "&amp;" is converted to "&" by libxml
regardless of the specified options.

It's as if the underlying C code is calling:

libxml->load_string(data, classname, options | LIBXML_NOENT);

(Note: not the real function names...)

Actual result:
--------------
Resolution:

There would seem to be two resolutions. Either:
a) Change the prototype so that the default value of $options is
LIBXML_NOENT, allowing this to be overridden by specifying the options.

OR

b) Create a special LIBXML flag especially for PHP, such as
LIBXML_KEEPENT that negates the LIBXML_NOENT flag.


Note: This is not an important bug for me, because I will just ditch
using SimpleXML and find another way, but I think it should still be on
the books as a bug.


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=49437&edit=1

Reply via email to