Skip to content

Commit 450e7be

Browse files
authored
Merge pull request microsoft#204196 from microsoft/tyriar/204195
Fix URL link detection when a path is in query string
2 parents 65b1781 + 7cd1f0d commit 450e7be

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/vs/workbench/contrib/terminalContrib/links/browser/terminalLinkParsing.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ enum RegexPathConstants {
315315
// '":; are allowed in paths but they are often separators so ignore them
316316
// Also disallow \\ to prevent a catastropic backtracking case #24795
317317
ExcludedPathCharactersClause = '[^\\0<>\\?\\s!`&*()\'":;\\\\]',
318-
ExcludedStartPathCharactersClause = '[^\\0<>\\s!`&*()\\[\\]\'":;\\\\]',
318+
ExcludedStartPathCharactersClause = '[^\\0<>\\?\\s!`&*()\\[\\]\'":;\\\\]',
319319

320320
WinOtherPathPrefix = '\\.\\.?|\\~',
321321
WinPathSeparatorClause = '(?:\\\\|\\/)',

src/vs/workbench/contrib/terminalContrib/links/test/browser/terminalLinkParsing.test.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -561,6 +561,14 @@ suite('TerminalLinkParsing', () => {
561561
] as IParsedLink[]
562562
);
563563
});
564+
test('should not detect links starting with ? within query strings that contain posix-style paths (#204195)', () => {
565+
// ? appended to the cwd will exist since it's just the cwd
566+
strictEqual(detectLinks(`http://foo.com/?bar=/a/b&baz=c`, os).some(e => e.path.text.startsWith('?')), false);
567+
});
568+
test('should not detect links starting with ? within query strings that contain Windows-style paths (#204195)', () => {
569+
// ? appended to the cwd will exist since it's just the cwd
570+
strictEqual(detectLinks(`http://foo.com/?bar=a:\\b&baz=c`, os).some(e => e.path.text.startsWith('?')), false);
571+
});
564572
}
565573
});
566574

0 commit comments

Comments
 (0)