From ab2887e423936c5f2f422c4462bc4ad1f382f712 Mon Sep 17 00:00:00 2001 From: Mateusz Turcza Date: Fri, 9 Aug 2019 23:01:13 +0200 Subject: [PATCH] Fix DOM Lexer for PHP versions older than 5.4 (#225) --- library/HTMLPurifier/Lexer/DOMLex.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/library/HTMLPurifier/Lexer/DOMLex.php b/library/HTMLPurifier/Lexer/DOMLex.php index b573426d..ca5f25b8 100644 --- a/library/HTMLPurifier/Lexer/DOMLex.php +++ b/library/HTMLPurifier/Lexer/DOMLex.php @@ -74,7 +74,12 @@ class HTMLPurifier_Lexer_DOMLex extends HTMLPurifier_Lexer } set_error_handler(array($this, 'muteErrorHandler')); - $doc->loadHTML($html, $options); + // loadHTML() fails on PHP 5.3 when second parameter is given + if ($options) { + $doc->loadHTML($html, $options); + } else { + $doc->loadHTML($html); + } restore_error_handler(); $body = $doc->getElementsByTagName('html')->item(0)-> //