0
0
mirror of https://github.com/ezyang/htmlpurifier.git synced 2024-12-22 16:31:53 +00:00

Update DOMLex.php

Also fixed another instance of "undefined property" error.
This commit is contained in:
Aman Patel 2021-05-21 16:31:01 -05:00 committed by GitHub
parent fb8ad91cac
commit f4fdd55ad2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -194,7 +194,7 @@ class HTMLPurifier_Lexer_DOMLex extends HTMLPurifier_Lexer
} elseif ($node->nodeType === XML_CDATA_SECTION_NODE) { } elseif ($node->nodeType === XML_CDATA_SECTION_NODE) {
// undo libxml's special treatment of <script> and <style> tags // undo libxml's special treatment of <script> and <style> tags
$last = end($tokens); $last = end($tokens);
$data = $node->data; $data = $node->data ?? "";
// (note $node->tagname is already normalized) // (note $node->tagname is already normalized)
if ($last instanceof HTMLPurifier_Token_Start && ($last->name == 'script' || $last->name == 'style')) { if ($last instanceof HTMLPurifier_Token_Start && ($last->name == 'script' || $last->name == 'style')) {
$new_data = trim($data); $new_data = trim($data);