Skip to content

Commit

Permalink
add security attributes to IxoLink
Browse files Browse the repository at this point in the history
  • Loading branch information
bernhard-efler committed Apr 19, 2021
1 parent 2223d1f commit da9bdc6
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/Type/Html/IxoLink.php
Expand Up @@ -76,7 +76,14 @@ public function html(): string
/** @var LinkType $link */
$link = Type::create($link['ixolink'], LinkType::serviceName());

return \sprintf('<a href="%s" target="%s">%s</a>', (string) $link, $link->target(), $this->insert->html());
$attr = [
'href="' . (string)$link . '"',
'target="' . $link->target() . '"',
];
if ($link->target() === '_blank') {
$attr[] = 'rel="noopener noreferrer"';
}
return '<a ' . \implode(' ', $attr) . '>' . $this->insert->html() . '</a>';
}

/**
Expand Down

0 comments on commit da9bdc6

Please sign in to comment.