Skip to content

Commit 265f1f4

Browse files
committed
ext/tidy: using tidyParseString when available instead for tidy::parseString().
1 parent f6380e4 commit 265f1f4

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

ext/tidy/config.m4

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,12 @@ if test "$PHP_TIDY" != "no"; then
6363
[],
6464
[-L$TIDY_LIBDIR])
6565

66+
PHP_CHECK_LIBRARY([$TIDY_LIB_NAME], [tidyParseString],
67+
[AC_DEFINE([HAVE_TIDYPARSESTRING], [1],
68+
[Define to 1 if Tidy library has the 'tidyParseString' function.])],
69+
[],
70+
[-L$TIDY_LIBDIR])
71+
6672
PHP_ADD_LIBRARY_WITH_PATH([$TIDY_LIB_NAME],
6773
[$TIDY_LIBDIR],
6874
[TIDY_SHARED_LIBADD])

ext/tidy/tidy.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -809,9 +809,13 @@ static zend_result php_tidy_parse_string(PHPTidyObj *obj, const char *string, ui
809809

810810
obj->ptdoc->initialized = true;
811811

812+
#ifdef HAVE_TIDYPARSESTRING
813+
if (tidyParseString(obj->ptdoc->doc, string) < 0) {
814+
#else
812815
tidyBufInit(&buf);
813816
tidyBufAttach(&buf, (byte *) string, len);
814817
if (tidyParseBuffer(obj->ptdoc->doc, &buf) < 0) {
818+
#endif
815819
php_error_docref(NULL, E_WARNING, "%s", obj->ptdoc->errbuf->bp);
816820
return FAILURE;
817821
}

0 commit comments

Comments
 (0)