|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2009-09-02 08:43 UTC] matt at matthewfagan dot com
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 25 09:00:02 2025 UTC |
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>&</data>", "SimpleXMLElement", 0); Expected result: ---------------- This should return "&", because I have explicity turned off the LIBXML_NOENT option. However, "&" 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.