php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #49437 Can't disable LIBXML_NOENT option
Submitted: 2009-09-02 05:30 UTC Modified: 2009-09-02 08:43 UTC
From: matt at matthewfagan dot com Assigned:
Status: Closed Package: SimpleXML related
PHP Version: 5.2.10 OS: ALL
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: matt at matthewfagan dot com
New email:
PHP Version: OS:

 

 [2009-09-02 05:30 UTC] 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.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-09-02 08:43 UTC] matt at matthewfagan dot com
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.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Dec 27 00:01:30 2024 UTC