| 1 | Patch-Source: https://github.com/php/php-src/commit/67259e451d5d58b4842776c5696a66d74e157609
|
| 2 | From 67259e451d5d58b4842776c5696a66d74e157609 Mon Sep 17 00:00:00 2001
|
| 3 | From: Niels Dossche <[email protected]>
|
| 4 | Date: Fri, 5 Jul 2024 23:34:09 +0200
|
| 5 | Subject: [PATCH] Fix GH-14834: Error installing PHP when --with-pear is used
|
| 6 |
|
| 7 | libxml2 2.13 makes changes to how the parsing state is set, update our
|
| 8 | code accordingly. In particular, it started reporting entities within
|
| 9 | attributes, while it should only report entities inside text nodes.
|
| 10 |
|
| 11 | Closes 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 |
|
| 19 | diff --git a/ext/xml/compat.c b/ext/xml/compat.c
|
| 20 | index 242cc4ba7c40c..5f55dc62b3687 100644
|
| 21 | |
| 22 | |
| 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 */
|
| 32 | diff --git a/ext/xml/tests/gh14834.phpt b/ext/xml/tests/gh14834.phpt
|
| 33 | new file mode 100644
|
| 34 | index 0000000000000..2781ba2ed0941
|
| 35 | |
| 36 | |
| 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'world">&foo;<![CDATA[ & ]]><?x & ?></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) " & "
|
| 65 | +string(1) "
|
| 66 | +"
|