Skip to content

[INFRA-1223] fix: open editor links from the anchor only - #10308

Merged
sriramveeraghanta merged 1 commit into
previewfrom
fix/infra-1223-link-click-handler
Nov 16, 2026
Merged

sriramveeraghanta merged 1 commit into
previewfrom
fix/infra-1223-link-click-handler

Conversation

@pablohashescobar

Copy link
Copy Markdown
Member

Description

The editor's link click handler took event.target as the link. When the click landed on an element inside the anchor, it fell back to the raw href from editor state, checked it with a pattern that does not normalise the value the way the browser's URL parser does, and passed it to window.open with a stored target and no noopener.

  • The handler resolves the anchor with closest("a") (inside the editor root) and opens only that anchor's browser-resolved href; the editor-state fallback is gone.
  • The same normalising check used at parse and render time (isDangerousHref, now exported) is applied at click time; file: and about: stay blocked.
  • Links open with noopener,noreferrer. Only _self is honoured as a target; anything else opens a new tab.

Behavior change: a link whose stored target is a named window now opens in a new tab.

Notes for review:

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • Feature (non-breaking change which adds functionality)
  • Improvement (change that would cause existing functionality to not work as expected)
  • Code refactoring
  • Performance improvements
  • Documentation update

Screenshots and Media (if applicable)

Test Scenarios

  • New packages/editor/src/extensions/__tests__/custom-link.test.ts: a click on an element inside a link opens the anchor's own URL with noopener,noreferrer, and isDangerousHref rejects whitespace- and control-character-prefixed schemes. Editor suite: 16 passed; the click test fails without the fix.

Not run in a browser. Please check manually: clicking plain and bold links in editable and read-only editors opens a new tab (not a popup window).

References

  • INFRA-1223

Created with Claude Code

…ved URL

The link click handler now resolves the anchor that contains the click target, uses only that anchor's browser-resolved href (never the mark attribute from the editor state), applies the shared dangerous-scheme check, and opens with noopener,noreferrer, honouring only _blank and _self as targets.
Copilot AI balanced review requested due to automatic review settings November 15, 2026 23:04

Copilot AI left a comment

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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

@coderabbitai

coderabbitai Bot commented Nov 15, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 28 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 10 included reviews currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: f4c45ed8-6b42-4b3c-be4b-a161fd46f7cf
Commits

Reviewing files that changed from the base of the PR and between 290383d and da04902.

Files selected for processing: 3

  • packages/editor/src/extensions/__tests__/custom-link.test.ts
  • packages/editor/src/extensions/custom-link/extension.tsx
  • packages/editor/src/extensions/custom-link/helpers/clickHandler.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@github-actions

Copy link
Copy Markdown

React Doctor found no new issues. 🎉

Reviewed by React Doctor for commit da04902.

@makeplane

makeplane Bot commented Nov 15, 2026

Copy link
Copy Markdown

@pablohashescobar pablohashescobar changed the title [INFRA-1223] fix(security): open editor links from the anchor only [INFRA-1223] fix: open editor links from the anchor only Nov 16, 2026

@sriramveeraghanta sriramveeraghanta left a comment

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.

LGTM. closest("a") plus the view.dom.contains check handles links inside marks and ignores outer anchors. Still worth the manual browser check (tab vs popup) the description asks for.

@sriramveeraghanta
sriramveeraghanta merged commit 0382084 into preview Nov 16, 2026
15 checks passed
@sriramveeraghanta
sriramveeraghanta deleted the fix/infra-1223-link-click-handler branch November 16, 2026 20:23
sriramveeraghanta pushed a commit that referenced this pull request Nov 16, 2026
The link click handler now resolves the anchor that contains the click target, uses only that anchor's browser-resolved href (never the mark attribute from the editor state), applies the shared dangerous-scheme check, and opens with noopener,noreferrer, honouring only _blank and _self as targets.
Pawel-Kranzberg pushed a commit to klazwi/pi-plane that referenced this pull request Nov 18, 2026
…0308)

The link click handler now resolves the anchor that contains the click target, uses only that anchor's browser-resolved href (never the mark attribute from the editor state), applies the shared dangerous-scheme check, and opens with noopener,noreferrer, honouring only _blank and _self as targets.

(cherry picked from commit d375d6d)
Pawel-Kranzberg added a commit to klazwi/pi-plane that referenced this pull request Nov 18, 2026
The handler resolves the clicked anchor with closest("a") and opens with
noopener,noreferrer (ported makeplane#10308); the test now builds that event and
covers the target rule and an anchor outside the editor.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants