You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on May 23, 2024. It is now read-only.
Thanks for the great library! Given the intended use-case of passing in HTML from something untrusted and then being able to sanitize and display it securely, it would be really cool if we could get some options to force rel and target on a tags. While rel="nofollow" and target="_blank" are "nice to have", rel="noopener" is certainly important for security and would be great if we could force it.
Config options could look something like this:
$sanitizer = HtmlSanitizer\Sanitizer::create([
'extensions' => ['basic', 'image', 'iframe'],
'tags' => [
'a' => [
/*
* If an array is provided, links targeting other hosts than one in this array
* will be disabled (the `href` attribute will be blank). This can be useful if you want
* to prevent links targeting external websites. Keep null to allow all hosts.
* Any allowed domain also includes its subdomains.
*
* Example:
* 'allowed_hosts' => ['trusted1.com', 'google.com'],
*/
'allowed_hosts' => null,
/*
* If true, mailto links will be accepted.
*/
'allow_mailto' => false,
/*
* Forces rel=nofollow in links.
*/
'force_rel_nofollow' => false,
/*
* Forces rel=noopener in links.
*/
'force_rel_noopener' => false,
/*
* Forces target=value unless set to false.
*/
'force_target' => false,
],
...
I just quickly threw this issue together so if you would prefer something in the form of a PR I can look into doing that instead.
The text was updated successfully, but these errors were encountered:
Thanks for the great library! Given the intended use-case of passing in HTML from something untrusted and then being able to sanitize and display it securely, it would be really cool if we could get some options to force
rel
andtarget
ona
tags. Whilerel="nofollow"
andtarget="_blank"
are "nice to have",rel="noopener"
is certainly important for security and would be great if we could force it.Config options could look something like this:
I just quickly threw this issue together so if you would prefer something in the form of a PR I can look into doing that instead.
The text was updated successfully, but these errors were encountered: