From fb8ad91cac37465b863dda1f24c08d1c64c3f3e1 Mon Sep 17 00:00:00 2001 From: Aman Patel Date: Thu, 20 May 2021 13:14:48 -0500 Subject: [PATCH] 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 ca5f25b8..3057068e 100644 --- a/library/HTMLPurifier/Lexer/DOMLex.php +++ b/library/HTMLPurifier/Lexer/DOMLex.php @@ -213,7 +213,7 @@ class HTMLPurifier_Lexer_DOMLex extends HTMLPurifier_Lexer // 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 @@ class HTMLPurifier_Lexer_DOMLex extends HTMLPurifier_Lexer } $array = array(); foreach ($node_map as $attr) { + if (!isset($attr->name)) continue; $array[$attr->name] = $attr->value; } return $array;