Fix preg_replace_callback() error in Html2Text - closes #5433

This commit is contained in:
FreeScout
2026-05-28 04:23:43 -07:00
parent 26ff8c73ab
commit afa0cb6ba5
2 changed files with 8 additions and 0 deletions

View File

@@ -2454,6 +2454,9 @@ class Helper
if ((int)ini_get('pcre.backtrack_limit') <= 1000000) {
ini_set('pcre.backtrack_limit', 1000000000);
}
if ((int)ini_get('pcre.recursion_limit') <= 1000000) {
ini_set('pcre.recursion_limit', 1000000000);
}
}
/**

View File

@@ -366,7 +366,12 @@ class Html2Text
{
$this->convertBlockquotes($text);
$this->convertPre($text);
$text_copy = $text;
$text = preg_replace($this->search, $this->replace, $text);
if ($text === null) {
$text = $text_copy;
$text_copy = null;
}
$text = preg_replace_callback($this->callbackSearch, array($this, 'pregCallback'), $text);
$text = $text ?? '';
$text = strip_tags($text);