php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #14850 Problems with XML and DTD entities
Submitted: 2002-01-04 10:09 UTC Modified: 2002-01-25 11:48 UTC
Votes:2
Avg. Score:4.0 ± 1.0
Reproduced:2 of 2 (100.0%)
Same Version:1 (50.0%)
Same OS:0 (0.0%)
From: mark at chesneycorp dot com Assigned:
Status: No Feedback Package: DOM XML related
PHP Version: 4.1.1 OS: FreeBSD 4.5-PRERELEASE
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 this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: mark at chesneycorp dot com
New email:
PHP Version: OS:

 

 [2002-01-04 10:09 UTC] mark at chesneycorp dot com
There are two instances where I am having problems with entities. test.php and test.xml below exhibit a problem with xml entities.

The output is:
Blah Blah ® Blah Blah

The expected output was:
Blah Blah ® Blah Blah

The second problem exhibited by test2.php and test2.xml has to do with DTD entities.

The output is:
Blah Blah 

The expected output was:
Blah Blah ® Blah Blah

The setup is PHP 4.1.1 with a patch to php_domxml.c from 1.67.2.9 to 1.90 that fixes a problem with PHP crashing with DTD entities.

test.php:
--
<?
$xml = "test.xml";
$doc = xmldocfile($xml);
$context = $doc->xpath_new_context();
$query = "//test";
$nodes = $context->xpath_eval($query);
$node = $nodes->nodeset[0]->children();
$content .= $node[0]->content;
echo htmlentities($content);
?>

test.xml:
--
<?xml version="1.0"?>
<test>Blah Blah &#174; Blah Blah</test>

test2.php:
--
<?
$xml = "test2.xml";
$doc = xmldocfile($xml);
$context = $doc->xpath_new_context();
$query = "//test";
$nodes = $context->xpath_eval($query);
$node = $nodes->nodeset[0]->children();
$content .= $node[0]->content;
echo htmlentities($content);
?>

test2.xml:
--
<?xml version="1.0"?>
<!DOCTYPE test [
<!ENTITY reg "&#174;">
]>
<test>Blah Blah &reg; Blah Blah</test>

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-01-04 13:39 UTC] mfischer@php.net
About Example 2:
Entity references defined in the document are their own nodes. You should carefully look at print_r($node);

Next please don't open one report about two things (even if they look the same).
 [2002-01-04 13:50 UTC] mfischer@php.net
For the first bug, you should consult tightly the libxml2 documentation. libxml2 does the conversion on its own and only hell knows why you get what you get.

It's probably a runtime configuration option of libxml2 which most likely also isn't implemented in the domxml interface. Or maybe its even expected. Anyway, best is you take a look at libxml2 directly .

Feedback.
 [2002-01-25 11:48 UTC] sander@php.net
No feedback.
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Sat Aug 17 23:01:27 2019 UTC