php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #28207 Wrong output in PHP 5 with XML Parser Functions
Submitted: 2004-04-28 17:18 UTC Modified: 2005-09-01 04:45 UTC
Votes:5
Avg. Score:4.4 ± 0.8
Reproduced:3 of 4 (75.0%)
Same Version:1 (33.3%)
Same OS:1 (33.3%)
From: bart at mediawave dot nl Assigned:
Status: Not a bug Package: XML related
PHP Version: 5CVS, 4CVS (2005-07-31) OS: *
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: bart at mediawave dot nl
New email:
PHP Version: OS:

 

 [2004-04-28 17:18 UTC] bart at mediawave dot nl
Description:
------------
The stream-oriented XML parser (formerly Expat) produces different output in PHP 5 than it did in PHP 4. I'm unable to read the 

<?xml version='1.0'?>
<!DOCTYPE chapter SYSTEM "/just/a/test.dtd" [
<!ENTITY plainEntity "FOO entity">
<!ENTITY systemEntity SYSTEM "xmltest2.xml">
]>

section of the XML document with PHP 5.

Reproduce code:
---------------
The code under "Example 3. External Entity Example" at http://www.php.net/manual/en/ref.xml.php

Expected result:
----------------
<?xml version='1.0'?>
<!DOCTYPE chapter SYSTEM "/just/a/test.dtd" [
<!ENTITY plainEntity "FOO entity">
<!ENTITY systemEntity SYSTEM "xmltest2.xml">
]>
<CHAPTER>
 <TITLE>Title &plainEntity;</TITLE>
 <PARA>
  <INFORMALTABLE>
   <TGROUP COLS="3">
    <TBODY>
     <ROW><ENTRY>a1</ENTRY><ENTRY MOREROWS="1">b1</ENTRY><ENTRY>c1</ENTRY></ROW>
     <ROW><ENTRY>a2</ENTRY><ENTRY>c2</ENTRY></ROW>
     <ROW><ENTRY>a3</ENTRY><ENTRY>b3</ENTRY><ENTRY>c3</ENTRY></ROW>
    </TBODY>
   </TGROUP>
  </INFORMALTABLE>
 </PARA>
 <?xml version="1.0"?>
<!DOCTYPE foo [
<!ENTITY testEnt "test entity">
]>
<FOO>
   <ELEMENT ATTRIB="value"></ELEMENT>
   &testEnt;
   This is some more PHP code being executed.
</FOO>
 <SECTION ID="about">
  <TITLE>About this Document</TITLE>
  <PARA>
   <!-- this is a comment -->
   Hi!  This is PHP version 4.3.6
  </PARA>
 </SECTION>
</CHAPTER>

parse complete

Actual result:
--------------
&plainEntity;<CHAPTER>
 <TITLE>Title &plainEntity;</TITLE>
 <PARA>
  <INFORMALTABLE>
   <TGROUP COLS="3">
    <TBODY>
     <ROW><ENTRY>a1</ENTRY><ENTRY MOREROWS="1">b1</ENTRY><ENTRY>c1</ENTRY></ROW>
     <ROW><ENTRY>a2</ENTRY><ENTRY>c2</ENTRY></ROW>
     <ROW><ENTRY>a3</ENTRY><ENTRY>b3</ENTRY><ENTRY>c3</ENTRY></ROW>
    </TBODY>
   </TGROUP>
  </INFORMALTABLE>
 </PARA>
 &systemEntity;
 <SECTION ID="about">
  <TITLE>About this Document</TITLE>
  <PARA>
   <-- this is a comment -->
   Hi!  This is PHP version 5.0.0RC2
  </PARA>
 </SECTION>
</CHAPTER>XML error: Undeclared entity warning at line 27

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-02-22 21:58 UTC] joern_h at gmx dot net
It seems that entity refs do not get expanded when there is a default handler registered. Instead the default handler gets called with the name of the entity. Surprisingly this behavior is the same in PHP4 and PHP5 (tested with latest snapshots).
 [2005-07-31 20:59 UTC] sniper@php.net
Happens when ext/xml is compiled with libxml instead of expat.

 [2005-09-01 04:45 UTC] rrichards@php.net
Entity issues have been fixed for a while. The remaining issues here are default handler issues.
See Bug #27908
Marking bogus as half of the issues fixed and the rest in already reported
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Apr 24 20:01:32 2024 UTC