mirror of
https://github.com/stablyai/orca.git
synced 2026-10-16 16:03:26 +00:00
fix: address pr-bug-scan validated finding from #6604
Added negative lookbehind (?<![A-Za-z]) to WINDOWS_ABSOLUTE_PATH_PATTERN so a URL scheme's 's' in 'https://' no longer matches as a 's://' drive path; bug case yields zero matches.
This commit is contained in:
@@ -68,6 +68,16 @@ describe('rich markdown terminal path paste', () => {
|
||||
).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:
|
||||
'<h1>Heading</h1><p>Visit <a href="https://acme.com">https://acme.com</a> for details.</p>'
|
||||
})
|
||||
).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'
|
||||
|
||||
@@ -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
|
||||
/(?:(?<![A-Za-z])[A-Za-z]:[\\/][^\s<>"|?*\r\n]+|\\\\[^\s\\/:*?"<>|\r\n]+\\[^\s\\/:*?"<>|\r\n]+(?:\\[^\s<>"|?*\r\n]+)*)/g
|
||||
|
||||
function readClipboardText(event: ClipboardEvent, type: string): string {
|
||||
return event.clipboardData?.getData(type) ?? ''
|
||||
|
||||
Reference in New Issue
Block a user