Merge pull request #105108 from DavidGoldman/master

Terminal: Support linking local file paths containing '+'
This commit is contained in:
Daniel Imms
2020-09-09 06:24:08 -07:00
committed by GitHub
2 changed files with 8 additions and 4 deletions
@@ -20,14 +20,14 @@ const pathPrefix = '(\\.\\.?|\\~)';
const pathSeparatorClause = '\\/';
// '":; are allowed in paths but they are often separators so ignore them
// Also disallow \\ to prevent a catastropic backtracking case #24798
const excludedPathCharactersClause = '[^\\0\\s!$`&*()\\[\\]+\'":;\\\\]';
const excludedPathCharactersClause = '[^\\0\\s!$`&*()\\[\\]\'":;\\\\]';
/** A regex that matches paths in the form /foo, ~/foo, ./foo, ../foo, foo/bar */
export const unixLocalLinkClause = '((' + pathPrefix + '|(' + excludedPathCharactersClause + ')+)?(' + pathSeparatorClause + '(' + excludedPathCharactersClause + ')+)+)';
export const winDrivePrefix = '(?:\\\\\\\\\\?\\\\)?[a-zA-Z]:';
const winPathPrefix = '(' + winDrivePrefix + '|\\.\\.?|\\~)';
const winPathSeparatorClause = '(\\\\|\\/)';
const winExcludedPathCharactersClause = '[^\\0<>\\?\\|\\/\\s!$`&*()\\[\\]+\'":;]';
const winExcludedPathCharactersClause = '[^\\0<>\\?\\|\\/\\s!$`&*()\\[\\]\'":;]';
/** A regex that matches paths in the form \\?\c:\foo c:\foo, ~\foo, .\foo, ..\foo, foo\bar */
export const winLocalLinkClause = '((' + winPathPrefix + '|(' + winExcludedPathCharactersClause + ')+)?(' + winPathSeparatorClause + '(' + winExcludedPathCharactersClause + ')+)+)';
@@ -19,7 +19,9 @@ const unixLinks = [
'./foo',
'../foo',
'/foo/bar',
'foo/bar'
'/foo/bar+more',
'foo/bar',
'foo/bar+more',
];
const windowsLinks = [
@@ -33,10 +35,12 @@ const windowsLinks = [
'~/foo',
'c:/foo/bar',
'c:\\foo\\bar',
'c:\\foo\\bar+more',
'c:\\foo/bar\\baz',
'foo/bar',
'foo/bar',
'foo\\bar'
'foo\\bar',
'foo\\bar+more',
];
interface LinkFormatInfo {