From 3ba61d332ff35164b35f7a5afd8abdfacde686ca Mon Sep 17 00:00:00 2001 From: orca-bug-scan-bot Date: Sun, 28 Jun 2026 13:11:38 -0700 Subject: [PATCH] fix: address pr-bug-scan validated finding from #6604 Added negative lookbehind (? { ).toBe(false) }) + it('does not treat a bare-domain auto-linked URL as a Windows drive path', () => { + expect( + shouldPasteTerminalWindowsPathAsPlainText({ + plainText: 'Heading\n\nVisit https://acme.com for details.', + htmlText: + '

Heading

Visit https://acme.com for details.

' + }) + ).toBe(false) + }) + it('inserts the plain clipboard text before TipTap can preserve broken link metadata', () => { const { editor, inserted } = makeEditor() const text = 'C:\\Users\\neil\\.claude\\CLAUDE.md' diff --git a/src/renderer/src/components/editor/rich-markdown-terminal-path-paste.ts b/src/renderer/src/components/editor/rich-markdown-terminal-path-paste.ts index cfdb7f422fd..5db624f4acc 100644 --- a/src/renderer/src/components/editor/rich-markdown-terminal-path-paste.ts +++ b/src/renderer/src/components/editor/rich-markdown-terminal-path-paste.ts @@ -4,8 +4,11 @@ type ClipboardAnchor = { href: string } +// The drive-letter alternative requires a non-letter boundary before the +// letter so a URL scheme's trailing char (e.g. the "s" in "https://") is not +// mistaken for a "X:/..." drive path, which would discard rich paste formatting. const WINDOWS_ABSOLUTE_PATH_PATTERN = - /(?:[A-Za-z]:[\\/][^\s<>"|?*\r\n]+|\\\\[^\s\\/:*?"<>|\r\n]+\\[^\s\\/:*?"<>|\r\n]+(?:\\[^\s<>"|?*\r\n]+)*)/g + /(?:(?"|?*\r\n]+|\\\\[^\s\\/:*?"<>|\r\n]+\\[^\s\\/:*?"<>|\r\n]+(?:\\[^\s<>"|?*\r\n]+)*)/g function readClipboardText(event: ClipboardEvent, type: string): string { return event.clipboardData?.getData(type) ?? ''