Skip to content

Commit

Permalink
fix: Invalid scheme check in Attr.TargetBlank (#363)
Browse files Browse the repository at this point in the history
  • Loading branch information
jstanden committed Jan 27, 2023
1 parent 78a9b4d commit 0176ef4
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion library/HTMLPurifier/AttrTransform/TargetBlank.php
Expand Up @@ -33,7 +33,11 @@ public function transform($attr, $config, $context)

// XXX Kind of inefficient
$url = $this->parser->parse($attr['href']);
$scheme = $url->getSchemeObj($config, $context);

// Ignore invalid schemes (e.g. `javascript:`)
if (!($scheme = $url->getSchemeObj($config, $context))) {
return $attr;
}

if ($scheme->browsable && !$url->isBenign($config, $context)) {
$attr['target'] = '_blank';
Expand Down

0 comments on commit 0176ef4

Please sign in to comment.