Skip to content

Commit 2969b3c

Browse files
committed
textproc/php81-xml: fix compatibility with libxml2>=2.13
Fix compatibility issue with libxml2>=2.13 which caused parse error on some XML files so that devel/pear work again with php81. See php/php-src#14834 for details. Approved by: portmgr blanket (backport trivial fix from upstream)
1 parent da4fd42 commit 2969b3c

2 files changed

Lines changed: 16 additions & 4 deletions

File tree

‎textproc/php81-xml/Makefile‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
PORTREVISION= 1
12
CATEGORIES= textproc
23

34
MASTERDIR= ${.CURDIR}/../../lang/php81
Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
--- compat.c.orig Tue Jul 20 10:55:02 2004
2-
+++ compat.c Tue Jul 20 10:55:55 2004
3-
@@ -16,6 +16,10 @@
1+
--- compat.c.orig 2025-07-01 21:17:52 UTC
2+
+++ compat.c
3+
@@ -14,6 +14,10 @@
44
+----------------------------------------------------------------------+
55
*/
66

@@ -9,5 +9,16 @@
99
+#endif
1010
+
1111
#include "php.h"
12-
#if defined(HAVE_LIBXML) && defined(HAVE_XML) && !defined(HAVE_LIBEXPAT)
12+
#if defined(HAVE_LIBXML) && (defined(HAVE_XML) || defined(HAVE_XMLRPC)) && !defined(HAVE_LIBEXPAT)
1313
#include "expat_compat.h"
14+
@@ -375,7 +379,9 @@ _get_entity(void *user, const xmlChar *name)
15+
if (ret == NULL)
16+
ret = xmlGetDocEntity(parser->parser->myDoc, name);
17+
18+
- if (ret == NULL || (parser->parser->instate != XML_PARSER_ENTITY_VALUE && parser->parser->instate != XML_PARSER_ATTRIBUTE_VALUE)) {
19+
+/* Fix parse error on some XML files so that devel/pear work again. */
20+
+/* See https://github.com/php/php-src/issues/14834 for details. */
21+
+ if (ret == NULL || parser->parser->instate == XML_PARSER_CONTENT) {
22+
if (ret == NULL || ret->etype == XML_INTERNAL_GENERAL_ENTITY || ret->etype == XML_INTERNAL_PARAMETER_ENTITY || ret->etype == XML_INTERNAL_PREDEFINED_ENTITY) {
23+
/* Predefined entities will expand unless no cdata handler is present */
24+
if (parser->h_default && ! (ret && ret->etype == XML_INTERNAL_PREDEFINED_ENTITY && parser->h_cdata)) {

0 commit comments

Comments
 (0)