8000 Update DOMLex.php by amanpatel · Pull Request #292 · ezyang/htmlpurifier · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Update DOMLex.php #292

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions library/HTMLPurifier/Lexer/DOMLex.php
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ protected function createStartNode($node, &$tokens, $collect, $config)
} elseif ($node->nodeType === XML_CDATA_SECTION_NODE) {
// undo libxml's special treatment of <script> and <style> tags
$last = end($tokens);
$data = $node->data;
$data = $node->data ?? "";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use of null coalesce operator should be reflected in min PHP version required in composer.json (e.g.: "php": ">=7.0"), otherwise the library will be broken on older installations.

// (note $node->tagname is already normalized)
if ($last instanceof HTMLPurifier_Token_Start && ($last->name == 'script' || $last->name == 'style')) {
$new_data = trim($data);
Expand All @@ -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
Expand Down Expand Up @@ -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;
Expand Down
0