Skip to content

Keep a file link plain when its text is the file's name as printed - #1553

Merged
nedtwigg merged 1 commit into
mainfrom
nightly/file-link-own-name
Nov 3, 2026
Merged

nedtwigg merged 1 commit into
mainfrom
nightly/file-link-own-name

Conversation

@dormouse-bot

Copy link
Copy Markdown
Collaborator

Since #1534, a file: hyperlink whose text is the file's own name gets the deceptive verdict when the name starts with punctuation (_app.tsx, @types.d.ts, -v1.md, #notes.md) or is stored decomposed (a macOS NFD café.md). The deceptive verdict leaves the link dialog with no Open action, and the host also rejects that verdict if its callback runs. This PR matches the link's path against the display text as printed, not only the normalized text, so those links are plain again. docs/specs/mouse-and-clipboard.md -> "OSC 8 hyperlinks" already says a file: target's own file name is not a host claim.

Cause. classifyDisplayMatch normalizes the text before comparing it with the path: NFKC, with leading punctuation and symbols removed. _app.tsx becomes app.tsx and no longer matches /repo/_app.tsx. #1534 also widened BARE_DOMAIN_RE to Unicode labels, so the normalized text now reads as a dotted host. That host differs from the file: URI's empty host, so the verdict is deceptive.

Where users hit it. activateTerminalLink (lib/src/lib/terminal-link-activation.ts) sends a link to requestExternalLinkConfirmation, which classifies it. That happens for every link on a host without toolControl, which includes Pocket's RemotePtyAdapter, so ls --hyperlink output on the phone hits it. On desktop it happens when the dor open preview fails and the link falls back to the dialog.

Tests. The new external-links.test.ts cases fail before the change and pass after it. They cover the four punctuation-led names, the NFD name, and the NFD name with a line suffix. Spoofing behavior does not change: text that matched the path after normalization still does, and github.com:443 over file:///repo/notes.txt is still deceptive. external-links, terminal-link-activation, and ExternalLinkModalHost tests pass locally.

classifyDisplayMatch compared a file: link's path only against the
normalized display text. Normalizing strips leading punctuation and
composes decomposed characters, so ls --hyperlink output for _app.tsx,
@types.d.ts, or a macOS NFD name no longer matched its own path, read as
a dotted host name, and was classified deceptive, leaving the dialog with
no open action. Match the path against the text as printed as well.
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying mouseterm with  Cloudflare Pages  Cloudflare Pages

Latest commit: 404d6dc
Status: ✅  Deploy successful!
Preview URL: https://eb549e97.mouseterm.pages.dev
Branch Preview URL: https://nightly-file-link-own-name.mouseterm.pages.dev

View logs

@nedtwigg
nedtwigg merged commit 552f638 into main Nov 3, 2026
18 checks passed
@nedtwigg
nedtwigg deleted the nightly/file-link-own-name branch November 3, 2026 14:39
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.

2 participants