Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add attribute rel to default attributes #584

Closed
jonasgrilleres opened this issue Nov 28, 2022 · 3 comments
Closed

Add attribute rel to default attributes #584

jonasgrilleres opened this issue Nov 28, 2022 · 3 comments
Labels

Comments

@jonasgrilleres
Copy link

It is recommended to add attribute: rel="noopener, noreferrer" to links opening in a new tab with attribute target="_blank". See tabnabbing.

In the current situation, it is not possible to use target and ref attributes together without overriding allowedAttributes list.

Does it make sense to add rel attribute in the list of the defaults attributes?

a: [ 'href', 'name', 'target' ],

@stale
Copy link

stale bot commented Mar 18, 2023

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Mar 18, 2023
@stale stale bot closed this as completed Apr 2, 2023
@danielnitu
Copy link

I ended up extending the default list, but it would be good to have rel included by default - or at least know why it's not included.

  const options = {
    allowedAttributes: {
      ...sanitize.defaults.allowedAttributes,
      a: ['href', 'name', 'target', 'rel'],
    },
  };

  const sanitizedHtml = sanitize(dirty, options)

@boutell
Copy link
Member

boutell commented Oct 5, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants