0
0
mirror of https://github.com/ezyang/htmlpurifier.git synced 2024-09-16 17:35:19 +00:00

fix: Invalid scheme check in Attr.TargetBlank (#363)

This commit is contained in:
Jeff Standen 2023-01-26 16:06:28 -08:00 committed by GitHub
parent 78a9b4d0da
commit 0176ef4bb6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -33,7 +33,11 @@ class HTMLPurifier_AttrTransform_TargetBlank extends HTMLPurifier_AttrTransform
// 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';