Skip to content
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

Multiple issues preventing removal of external references #50

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
10 changes: 4 additions & 6 deletions src/Sanitizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ protected function cleanAttributesOnWhitelist(\DOMElement $element)
{
for ($x = $element->attributes->length - 1; $x >= 0; $x--) {
// get attribute name
$attrName = $element->attributes->item($x)->name;
$attrName = $element->attributes->item($x)->nodeName;

// Remove attribute if not in whitelist
if (!in_array(strtolower($attrName), $this->allowedAttrs) && !$this->isAriaAttribute(strtolower($attrName)) && !$this->isDataAttribute(strtolower($attrName))) {
Expand Down Expand Up @@ -515,13 +515,11 @@ protected function hasRemoteReference($value)
$value = $this->removeNonPrintableCharacters($value);

$wrapped_in_url = preg_match('~^url\(\s*[\'"]\s*(.*)\s*[\'"]\s*\)$~xi', $value, $match);
if (!$wrapped_in_url){
return false;
if ($wrapped_in_url){
$value = trim($match[1], '\'"');
}

$value = trim($match[1], '\'"');

return preg_match('~^((https?|ftp|file):)?//~xi', $value);
return preg_match('~^((http|https|ftp|ftps|file):)?//~xi', $value);
Copy link
Contributor

@xerc xerc Feb 14, 2022

Choose a reason for hiding this comment

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

return preg_match('~^((https?|s?ftps?|file):)?//~xi', $value);

}

/**
Expand Down