php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #42139 XMLReader option constants are broken with respect to open() and XML()
Submitted: 2007-07-29 12:53 UTC Modified: 2007-09-20 19:27 UTC
From: gwynne@php.net Assigned: rrichards (profile)
Status: Closed Package: XML Reader
PHP Version: 5CVS-2007-07-29 (CVS) OS: MacOS/Darwin 10.4.10/8.10.1
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: gwynne@php.net
New email:
PHP Version: OS:

 

 [2007-07-29 12:53 UTC] gwynne@php.net
Description:
------------
The XMLReader constants for parser options (LOADDTD, SUBST_ENTITIES, etc.) don't work when passed as the third parameter to XMLReader::open() or XMLReader::XML(). Their values are incorrect for the xmlreader API; they're parser property names, not option bitmasks. The XML() method also ignores the options parameter completely.

This is partially a documentation problem, but also involves broken functionality in the xmlreader extension. Suggested fix is to either:
- remove the options parameters completely from both methods and their documentation
- fix the XML() method to read the options and document both functions as using the LIBXML_* constants (fix the docs to match the code), or
- modify both XML() and open() to interpret the options passed as properties (fix the code to match the docs)

Reproduce code:
---------------
<?php
$xml = <<<XML
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE root [
<!ELEMENT root ANY>
<!ENTITY x "y">
]>
<root>&x;</root>
XML;
$reader = new XMLReader;
$reader->XML( $xml, NULL, XMLReader::SUBST_ENTITIES );
// or: $reader->XML( $xml, NULL, LIBXML_NOENT );
while ( $reader->read() )
 echo "{$reader->nodeType}, {$reader->name}, {$reader->value}\n";
$reader->close();
?>

Expected result:
----------------
10, root, 
1, root, 
3, #text, y
15, root, 


Actual result:
--------------
10, root, 
1, root, 
5, x, 
15, root, 


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-07-30 12:44 UTC] rrichards@php.net
They are options - properties method was old name/method in libxml2 (see Table 338. XMLReader Parser Options - in XMLReader docs), though it needs to be implemented for that method.
Assign to self
 [2007-09-20 19:27 UTC] rrichards@php.net
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.

libxml2-2.6.28+ is required . It accepts the LIBXML_ constants just as the open() method does:
$reader->XML( $xml, NULL, LIBXML_NOENT );
the XMLReader properties are used with the set/getParserProperty() methods.
Docs will be updated
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 14:01:29 2024 UTC