Skip to content

Stop adding “noreferrer” to external links.#26968

Merged
adamsilverstein merged 24 commits into
WordPress:trunkfrom
adamsilverstein:remove/noreferrer
Apr 15, 2026
Merged

Stop adding “noreferrer” to external links.#26968
adamsilverstein merged 24 commits into
WordPress:trunkfrom
adamsilverstein:remove/noreferrer

Conversation

@adamsilverstein
Copy link
Copy Markdown
Member

@adamsilverstein adamsilverstein commented Nov 13, 2020

Description

Fixes #26914.

Removes the noreferrer value from the rel attribute on external links generated by the editor, admin UI, and block output. noopener is retained where needed to prevent reverse-tabnabbing on target="_blank" links.

Scope

The change touches two groups of links:

  • Admin-UI links (ExternalLink component, More Menus in editor/edit-widgets/customize-widgets, media-categories "view more" links, editor-only links in site-logo and categories): wp-admin sends Referrer-Policy: strict-origin-when-cross-origin via wp_admin_headers — which is also the modern browser default — so only the origin is sent, never full URLs or query strings. Removing noreferrer here does not leak sensitive admin paths.
  • Front-end post content (latest-posts, button, image block output; the link format in format-library/src/link/utils.js; the phrasing-content paste reducer; and the associated test fixtures): sharing the referrer is the expected web-platform default, and the site's own Referrer-Policy governs what is sent.

File block — excluded from this PR

Per @t-hamano's review, changes to the File block have been deferred to a separate follow-up PR #77345. The File block's save() function deterministically generates the rel attribute, so changing its output invalidates existing saved File blocks on reload. The follow-up will remove both noreferrer AND noopener in one pass, with a proper new deprecation to migrate existing content cleanly.

See discussion: #26914 (comment)

How has this been tested?

  • Unit tests and snapshots updated (npm run test:unit)
  • E2E tests for buttons, links, and pattern overrides pass against updated rel output

Types of changes

Bug fix / behavior change — removes noreferrer from editor-generated external links. One breaking change for @wordpress/components consumers: ExternalLink no longer adds noreferrer by default (documented in the components CHANGELOG).

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code follows the accessibility standards.
  • My code has proper inline documentation.
  • I've included developer documentation if appropriate.
  • I've updated all React Native files affected by any refactorings/renamings in this PR.

Comment thread packages/block-library/src/file/save.js Outdated
Comment thread packages/e2e-tests/fixtures/blocks/core__file__new-window.html Outdated
@talldan talldan added [Feature] Link Editing Link components (LinkControl, URLInput) and integrations (RichText link formatting) Backport to WP Beta/RC labels Nov 24, 2020
@talldan talldan modified the milestones: WordPress 5.x, 5.6 Nov 24, 2020
Base automatically changed from master to trunk March 1, 2021 15:44
@adamsilverstein
Copy link
Copy Markdown
Member Author

Looks like this dropped off my radar. I will try to revisit soon and land this. As far as I can tell, the only outstanding item (other than resolving merge conflicts) was adding a deprecation for the file block. Also, I will review the codebase to make sure more noreferrer links have been added in the meantime.

@adamsilverstein adamsilverstein requested review from jsnajdr and removed request for fabiankaegy March 26, 2026 16:14
The deprecated save functions must match old saved content in the
database (which has noreferrer noopener). Only the current save
function should output noopener alone.
@adamsilverstein adamsilverstein requested a review from a team as a code owner April 13, 2026 22:08
@github-actions github-actions Bot added [Package] Components /packages/components [Package] Blocks /packages/blocks [Package] Editor /packages/editor [Package] Block library /packages/block-library [Package] Format library /packages/format-library [Package] Block editor /packages/block-editor [Package] Edit Widgets /packages/edit-widgets labels Apr 13, 2026
@adamsilverstein adamsilverstein requested a review from talldan April 13, 2026 22:09
@adamsilverstein
Copy link
Copy Markdown
Member Author

@Krinkle - thanks for reviewing. I have resolved merge conflicts, this should be ready to merge once CI is green.

Copy link
Copy Markdown
Member

@jsnajdr jsnajdr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good 👍 Given that we now have the global Referrer-Policy and that modern browsers send only origin by default, the original reasons why referrers were dangerous (leaking URL details) no longer hold, they've been solved at web platform level.

Similarly, modern browsers set noopener automatically for target="blank", so the second ubiquitous rel value can be removed, too. That will also completely remove a lot of the NEW_TAB_REL code.

Comment thread packages/block-library/src/file/save.js Outdated
rel={
textLinkTarget ? 'noreferrer noopener' : undefined
}
rel={ textLinkTarget ? 'noopener' : undefined }
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change may break blocks, so I think we'll need to add a new migration. Try the following steps:

  1. Check out the trunk branch
  2. Insert a File block
  3. Attach a PDF file and enable "Open in new tab"
  4. Save the post
  5. Check out the remove/noreferrer branch
  6. Reload your browser
  7. The block is broken

Perhaps we can exclude the File block in this PR. To avoid adding multiple block migrations, it might be better to submit a separate PR specifically for the File block and then remove noreferer, noopener all at once.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should do a migration. Then it makes sense to remove both noreferrer and noopener in one PR.

We did a similar migration in #43050, for a similarly "banal" change--changing the value of an aria-label attribute. The change doesn't need to be big and serious to warrant a migration script.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be great to land #73116, so we don't have to introduce deprecations for every minor change.

Copy link
Copy Markdown
Member Author

@adamsilverstein adamsilverstein Apr 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps we can exclude the File block in this PR.

Good idea @t-hamano - I am going to exclude the File block for now, and open a separate PR just for it.

We should do a migration.

I will include a migration in the new PR.

It would be great to land #73116, so we don't have to introduce deprecations for every minor change.

@Mamaduka so after that merges, we wouldn't need a migration at all?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed changes to File block in 2f2f030

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Follow up PR to update the File block, including migration: #77345

The File block's save function deterministically generates the rel
attribute. Changing its output invalidates existing saved blocks on
reload. Defer to a follow-up PR that removes both noreferrer and
noopener together with a proper deprecation to handle migration
cleanly.
# Conflicts:
#	packages/blocks/src/api/raw-handling/phrasing-content-reducer.ts
#	packages/components/CHANGELOG.md
adamsilverstein added a commit to adamsilverstein/gutenberg that referenced this pull request Apr 14, 2026
The File block's save function previously added rel="noreferrer noopener"
to the text link when opened in a new tab. Modern browsers apply noopener
implicitly for target="_blank" (Chrome 88+, Firefox 79+, Safari 12.1+),
and noreferrer blocks legitimate referrer tracking without meaningful
security benefit on supported browsers.

Add a new v4 deprecation mirroring the current block schema but with the
previous save output so existing saved blocks migrate cleanly on reload.

Fixture added: core__file__new-window__deprecated-2 exercises the v4
migration path (input has rel="noreferrer noopener", output has no rel).

Follow-up to WordPress#26968 per review feedback from @t-hamano.
@t-hamano t-hamano dismissed their stale review April 15, 2026 09:10

Changes to the File block were excluded.

Resolve CHANGELOG conflict: preserve the ExternalLink breaking-change
note in Unreleased and keep the 32.6.0 release section from trunk.
@adamsilverstein adamsilverstein merged commit f75a114 into WordPress:trunk Apr 15, 2026
40 checks passed
@github-project-automation github-project-automation Bot moved this from PR needs review to Done in Increase Gutenberg Extensibility Apr 15, 2026
@github-actions github-actions Bot added this to the Gutenberg 23.1 milestone Apr 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Feature] Link Editing Link components (LinkControl, URLInput) and integrations (RichText link formatting) [Package] Block editor /packages/block-editor [Package] Block library /packages/block-library [Package] Blocks /packages/blocks [Package] Components /packages/components [Package] Edit Widgets /packages/edit-widgets [Package] Editor /packages/editor [Package] Format library /packages/format-library [Type] Enhancement A suggestion for improvement.

Projects

Development

Successfully merging this pull request may close these issues.

Stop adding rel=noreferrer to links that open in a new tab

7 participants