Skip to content

Commit ebbb1b4

Browse files
devnexenpetk
andcommitted
Fix phpGH-19021: improve tidyOptGetCategory detection
We now check both this symbol and TidyInternalCategory presence. Co-authored-by: Peter Kokot <[email protected]>
1 parent cf3b70d commit ebbb1b4

File tree

2 files changed

+27
-7
lines changed

2 files changed

+27
-7
lines changed

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@ PHP NEWS
6464
- Standard:
6565
. Fix shm corruption with coercion in options of unserialize(). (nielsdos)
6666

67+
- Tidy:
68+
. Fixed GH-19021 (improved tidyOptGetCategory detection).
69+
(arjendekorte, David Carlier, Peter Kokot)
70+
6771
- XMLReader:
6872
. Fix arginfo/zpp violations when LIBXML_SCHEMAS_ENABLED is not available.
6973
(nielsdos)

ext/tidy/config.m4

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,16 +62,32 @@ if test "$PHP_TIDY" != "no"; then
6262
AC_DEFINE(HAVE_TIDYRELEASEDATE,1,[ ])
6363
], [], [])
6464

65-
dnl The tidyOptGetCategory function (added in libtidy 5.4.0) if only useable
66-
dnl if TidyInternalCategory (added in libtidy 5.6.0) is also present.
67-
PHP_CHECK_LIBRARY($TIDY_LIB_NAME,TidyInternalCategory,
68-
[
69-
AC_DEFINE(HAVE_TIDYOPTGETCATEGORY,1,[ ])
70-
], [], [])
71-
7265
PHP_ADD_LIBRARY_WITH_PATH($TIDY_LIB_NAME, $TIDY_LIBDIR, TIDY_SHARED_LIBADD)
7366
PHP_ADD_INCLUDE($TIDY_INCDIR)
7467

68+
old_CPPFLAGS=$CPPFLAGS
69+
CPPFLAGS=-I$TIDY_INCDIR
70+
71+
dnl The tidyOptGetCategory function (added in tidy-html5 5.4.0) is only
72+
dnl useable if TidyInternalCategory (added in tidy-html5 5.6.0) is also
73+
dnl present.
74+
AC_CACHE_CHECK([for tidyOptGetCategory], [php_ac_cv_have_tidyoptgetcategory],
75+
[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <tidy.h>],[
76+
TidyDoc doc = tidyCreate();
77+
TidyOption badopt = tidyGetOptionByName(doc, "<bad>");
78+
Bool v = (tidyOptGetCategory(badopt) == TidyInternalCategory);
79+
(void)v;
80+
tidyRelease(doc);
81+
])],
82+
[php_ac_cv_have_tidyoptgetcategory=yes],
83+
[php_ac_cv_have_tidyoptgetcategory=no])
84+
])
85+
AS_VAR_IF([php_ac_cv_have_tidyoptgetcategory], [yes],
86+
[AC_DEFINE([HAVE_TIDYOPTGETCATEGORY], [1],
87+
[Define to 1 if tidyOptGetCategory is available.])])
88+
89+
CPPFLAGS=$old_CPPFLAGS
90+
7591
dnl Add -Wno-ignored-qualifiers as this is an issue upstream
7692
TIDY_COMPILER_FLAGS="$TIDY_CFLAGS -Wno-ignored-qualifiers -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1"
7793
PHP_NEW_EXTENSION(tidy, tidy.c, $ext_shared,, $TIDY_COMPILER_FLAGS)

0 commit comments

Comments
 (0)