projects/aports·blob master · refs

66 lines · 2.3 KiB

1Patch-Source: https://github.com/php/php-src/commit/67259e451d5d58b4842776c5696a66d74e157609
2From 67259e451d5d58b4842776c5696a66d74e157609 Mon Sep 17 00:00:00 2001
3From: Niels Dossche <[email protected]>
4Date: Fri, 5 Jul 2024 23:34:09 +0200
5Subject: [PATCH] Fix GH-14834: Error installing PHP when --with-pear is used
6
7libxml2 2.13 makes changes to how the parsing state is set, update our
8code accordingly. In particular, it started reporting entities within
9attributes, while it should only report entities inside text nodes.
10
11Closes GH-14837.
12---
13 NEWS | 2 ++
14 ext/xml/compat.c | 2 +-
15 ext/xml/tests/gh14834.phpt | 29 +++++++++++++++++++++++++++++
16 3 files changed, 32 insertions(+), 1 deletion(-)
17 create mode 100644 ext/xml/tests/gh14834.phpt
18
19diff --git a/ext/xml/compat.c b/ext/xml/compat.c
20index 242cc4ba7c40c..5f55dc62b3687 100644
21--- a/ext/xml/compat.c
22+++ b/ext/xml/compat.c
23@@ -376,7 +376,7 @@
24 ret = xmlGetDocEntity(parser->parser->myDoc, name);
25
26 ZEND_DIAGNOSTIC_IGNORED_START("-Wdeprecated-declarations")
27- if (ret == NULL || (parser->parser->instate != XML_PARSER_ENTITY_VALUE && parser->parser->instate != XML_PARSER_ATTRIBUTE_VALUE)) {
28+ if (ret == NULL || parser->parser->instate == XML_PARSER_CONTENT) {
29 ZEND_DIAGNOSTIC_IGNORED_END
30 if (ret == NULL || ret->etype == XML_INTERNAL_GENERAL_ENTITY || ret->etype == XML_INTERNAL_PARAMETER_ENTITY || ret->etype == XML_INTERNAL_PREDEFINED_ENTITY) {
31 /* Predefined entities will expand unless no cdata handler is present */
32diff --git a/ext/xml/tests/gh14834.phpt b/ext/xml/tests/gh14834.phpt
33new file mode 100644
34index 0000000000000..2781ba2ed0941
35--- /dev/null
36+++ b/ext/xml/tests/gh14834.phpt
37@@ -0,0 +1,29 @@
38+--TEST--
39+GH-14834 (Error installing PHP when --with-pear is used)
40+--EXTENSIONS--
41+xml
42+--FILE--
43+<?php
44+$xml = <<<XML
45+<?xml version="1.0" encoding="UTF-8"?>
46+<!DOCTYPE root [
47+ <!ENTITY foo "ent">
48+]>
49+<root>
50+ <element hint="hello&apos;world">&foo;<![CDATA[ &amp; ]]><?x &amp; ?></element>
51+</root>
52+XML;
53+
54+$parser = xml_parser_create();
55+xml_set_character_data_handler($parser, function($_, $data) {
56+ var_dump($data);
57+});
58+xml_parse($parser, $xml, true);
59+?>
60+--EXPECT--
61+string(3) "
62+ "
63+string(3) "ent"
64+string(7) " &amp; "
65+string(1) "
66+"