From fb8ad91cac37465b863dda1f24c08d1c64c3f3e1 Mon Sep 17 00:00:00 2001 From: Aman Patel Date: Thu, 20 May 2021 13:14:48 -0500 Subject: [PATCH 1/2] Update DOMLex.php Fixed two issues where property references that don't exist cause errors on PHP 8 (on docker setup by "tiredofit"). --- library/HTMLPurifier/Lexer/DOMLex.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/library/HTMLPurifier/Lexer/DOMLex.php b/library/HTMLPurifier/Lexer/DOMLex.php index ca5f25b84..3057068e6 100644 --- a/library/HTMLPurifier/Lexer/DOMLex.php +++ b/library/HTMLPurifier/Lexer/DOMLex.php @@ -213,7 +213,7 @@ protected function createStartNode($node, &$tokens, $collect, $config) // this is code is only invoked for comments in script/style in versions // of libxml pre-2.6.28 (regular comments, of course, are still // handled regularly) - $tokens[] = $this->factory->createComment($node->data); + $tokens[] = $this->factory->createComment($node->data ?? null); return false; } elseif ($node->nodeType !== XML_ELEMENT_NODE) { // not-well tested: there may be other nodes we have to grab @@ -264,6 +264,7 @@ protected function transformAttrToAssoc($node_map) } $array = array(); foreach ($node_map as $attr) { + if (!isset($attr->name)) continue; $array[$attr->name] = $attr->value; } return $array; From f4fdd55ad28ef4c3d669b0d7735cf137bd74d344 Mon Sep 17 00:00:00 2001 From: Aman Patel Date: Fri, 21 May 2021 16:31:01 -0500 Subject: [PATCH 2/2] Update DOMLex.php Also fixed another instance of "undefined property" error. --- library/HTMLPurifier/Lexer/DOMLex.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/HTMLPurifier/Lexer/DOMLex.php b/library/HTMLPurifier/Lexer/DOMLex.php index 3057068e6..16a8e93ba 100644 --- a/library/HTMLPurifier/Lexer/DOMLex.php +++ b/library/HTMLPurifier/Lexer/DOMLex.php @@ -194,7 +194,7 @@ protected function createStartNode($node, &$tokens, $collect, $config) } elseif ($node->nodeType === XML_CDATA_SECTION_NODE) { // undo libxml's special treatment of