LinkTransformer: Don't open external urls in iFrames

fixes #4449
This commit is contained in:
Johannes Meyer 2021-07-21 08:24:54 +02:00
parent 8b5bc6950b
commit b39d9d6746
1 changed files with 6 additions and 4 deletions

View File

@ -60,10 +60,12 @@ class LinkTransformer extends HTMLPurifier_AttrTransform
$attr['class'] = 'with-thumbnail';
}
if ((! isset($attr['target']) || ! in_array($attr['target'], ['_blank', '_self']))
&& ($useIframe || $url->isExternal())
) {
$attr['href'] = Url::fromPath('iframe', ['url' => $url])->getAbsoluteUrl();
if ((! isset($attr['target']) || ! in_array($attr['target'], ['_blank', '_self']))) {
if ($useIframe) {
$attr['href'] = Url::fromPath('iframe', ['url' => $url])->getAbsoluteUrl();
} elseif ($url->isExternal()) {
$attr['target'] = '_blank';
}
}
return $attr;