Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ext/xml/compat.c
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ _get_entity(void *user, const xmlChar *name)
if (ret == NULL)
ret = xmlGetDocEntity(parser->parser->myDoc, name);

if (ret == NULL || (parser->parser->instate != XML_PARSER_ENTITY_VALUE && parser->parser->instate != XML_PARSER_ATTRIBUTE_VALUE)) {
if (ret == NULL || parser->parser->instate == XML_PARSER_CONTENT) {
if (ret == NULL || ret->etype == XML_INTERNAL_GENERAL_ENTITY || ret->etype == XML_INTERNAL_PARAMETER_ENTITY || ret->etype == XML_INTERNAL_PREDEFINED_ENTITY) {
/* Predefined entities will expand unless no cdata handler is present */
if (parser->h_default && ! (ret && ret->etype == XML_INTERNAL_PREDEFINED_ENTITY && parser->h_cdata)) {
Expand Down
29 changes: 29 additions & 0 deletions ext/xml/tests/gh14834.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
--TEST--
GH-14834 (Error installing PHP when --with-pear is used)
--EXTENSIONS--
xml
--FILE--
<?php
$xml = <<<XML
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE root [
<!ENTITY foo "ent">
]>
<root>
<element hint="hello&apos;world">&foo;<![CDATA[ &amp; ]]><?x &amp; ?></element>
</root>
XML;

$parser = xml_parser_create();
xml_set_character_data_handler($parser, function($_, $data) {
var_dump($data);
});
xml_parse($parser, $xml, true);
?>
--EXPECT--
string(3) "
"
string(3) "ent"
string(7) " &amp; "
string(1) "
"