@@ -16,6 +16,10 @@ public class PathEscapingTests
16
16
[ InlineData ( "C:\\ look\\ an*\\ here.ps1" , "C:\\ look\\ an`*\\ here.ps1" ) ]
17
17
[ InlineData ( "/Users/me/Documents/?here.ps1" , "/Users/me/Documents/`?here.ps1" ) ]
18
18
[ InlineData ( "/Brackets [and s]paces/path.ps1" , "/Brackets `[and s`]paces/path.ps1" ) ]
19
+ [ InlineData ( "/CJK.chars/脚本/hello.ps1" , "/CJK.chars/脚本/hello.ps1" ) ]
20
+ [ InlineData ( "/CJK.chars/脚本/[hello].ps1" , "/CJK.chars/脚本/`[hello`].ps1" ) ]
21
+ [ InlineData ( "C:\\ Animals\\ утка\\ quack.ps1" , "C:\\ Animals\\ утка\\ quack.ps1" ) ]
22
+ [ InlineData ( "C:\\ &nimals\\ утка\\ qu*ck?.ps1" , "C:\\ &nimals\\ утка\\ qu`*ck`?.ps1" ) ]
19
23
public void CorrectlyGlobEscapesPaths_NoSpaces ( string unescapedPath , string escapedPath )
20
24
{
21
25
string extensionEscapedPath = PowerShellContext . GlobEscapePath ( unescapedPath ) ;
@@ -32,12 +36,37 @@ public void CorrectlyGlobEscapesPaths_NoSpaces(string unescapedPath, string esca
32
36
[ InlineData ( "C:\\ look\\ an*\\ here.ps1" , "C:\\ look\\ an`*\\ here.ps1" ) ]
33
37
[ InlineData ( "/Users/me/Documents/?here.ps1" , "/Users/me/Documents/`?here.ps1" ) ]
34
38
[ InlineData ( "/Brackets [and s]paces/path.ps1" , "/Brackets` `[and` s`]paces/path.ps1" ) ]
39
+ [ InlineData ( "/CJK chars/脚本/hello.ps1" , "/CJK` chars/脚本/hello.ps1" ) ]
40
+ [ InlineData ( "/CJK chars/脚本/[hello].ps1" , "/CJK` chars/脚本/`[hello`].ps1" ) ]
41
+ [ InlineData ( "C:\\ Animal s\\ утка\\ quack.ps1" , "C:\\ Animal` s\\ утка\\ quack.ps1" ) ]
42
+ [ InlineData ( "C:\\ &nimals\\ утка\\ qu*ck?.ps1" , "C:\\ &nimals\\ утка\\ qu`*ck`?.ps1" ) ]
35
43
public void CorrectlyGlobEscapesPaths_Spaces ( string unescapedPath , string escapedPath )
36
44
{
37
45
string extensionEscapedPath = PowerShellContext . GlobEscapePath ( unescapedPath , escapeSpaces : true ) ;
38
46
Assert . Equal ( escapedPath , extensionEscapedPath ) ;
39
47
}
40
48
49
+ [ Theory ]
50
+ [ InlineData ( "DebugTest.ps1" , "'DebugTest.ps1'" ) ]
51
+ [ InlineData ( "../../DebugTest.ps1" , "'../../DebugTest.ps1'" ) ]
52
+ [ InlineData ( "C:\\ Users\\ me\\ Documents\\ DebugTest.ps1" , "'C:\\ Users\\ me\\ Documents\\ DebugTest.ps1'" ) ]
53
+ [ InlineData ( "/home/me/Documents/weird&folder/script.ps1" , "'/home/me/Documents/weird&folder/script.ps1'" ) ]
54
+ [ InlineData ( "./path/with some/spaces" , "'./path/with some/spaces'" ) ]
55
+ [ InlineData ( "C:\\ path\\ with[some]brackets\\ file.ps1" , "'C:\\ path\\ with[some]brackets\\ file.ps1'" ) ]
56
+ [ InlineData ( "C:\\ look\\ an*\\ here.ps1" , "'C:\\ look\\ an*\\ here.ps1'" ) ]
57
+ [ InlineData ( "/Users/me/Documents/?here.ps1" , "'/Users/me/Documents/?here.ps1'" ) ]
58
+ [ InlineData ( "/Brackets [and s]paces/path.ps1" , "'/Brackets [and s]paces/path.ps1'" ) ]
59
+ [ InlineData ( "/file path/that isn't/normal/" , "'/file path/that isn''t/normal/'" ) ]
60
+ [ InlineData ( "/CJK.chars/脚本/hello.ps1" , "'/CJK.chars/脚本/hello.ps1'" ) ]
61
+ [ InlineData ( "/CJK chars/脚本/[hello].ps1" , "'/CJK chars/脚本/[hello].ps1'" ) ]
62
+ [ InlineData ( "C:\\ Animal s\\ утка\\ quack.ps1" , "'C:\\ Animal s\\ утка\\ quack.ps1'" ) ]
63
+ [ InlineData ( "C:\\ &nimals\\ утка\\ qu*ck?.ps1" , "'C:\\ &nimals\\ утка\\ qu*ck?.ps1'" ) ]
64
+ public void CorrectlyQuoteEscapesPaths ( string unquotedPath , string expectedQuotedPath )
65
+ {
66
+ string extensionQuotedPath = PowerShellContext . QuoteEscapeString ( unquotedPath ) ;
67
+ Assert . Equal ( expectedQuotedPath , extensionQuotedPath ) ;
68
+ }
69
+
41
70
[ Theory ]
42
71
[ InlineData ( "DebugTest.ps1" , "'DebugTest.ps1'" ) ]
43
72
[ InlineData ( "../../DebugTest.ps1" , "'../../DebugTest.ps1'" ) ]
@@ -49,7 +78,11 @@ public void CorrectlyGlobEscapesPaths_Spaces(string unescapedPath, string escape
49
78
[ InlineData ( "/Users/me/Documents/?here.ps1" , "'/Users/me/Documents/`?here.ps1'" ) ]
50
79
[ InlineData ( "/Brackets [and s]paces/path.ps1" , "'/Brackets `[and s`]paces/path.ps1'" ) ]
51
80
[ InlineData ( "/file path/that isn't/normal/" , "'/file path/that isn''t/normal/'" ) ]
52
- public void CorrectlyFullyEscapesPaths_Spaces ( string unescapedPath , string escapedPath )
81
+ [ InlineData ( "/CJK.chars/脚本/hello.ps1" , "'/CJK.chars/脚本/hello.ps1'" ) ]
82
+ [ InlineData ( "/CJK chars/脚本/[hello].ps1" , "'/CJK chars/脚本/`[hello`].ps1'" ) ]
83
+ [ InlineData ( "C:\\ Animal s\\ утка\\ quack.ps1" , "'C:\\ Animal s\\ утка\\ quack.ps1'" ) ]
84
+ [ InlineData ( "C:\\ &nimals\\ утка\\ qu*ck?.ps1" , "'C:\\ &nimals\\ утка\\ qu`*ck`?.ps1'" ) ]
85
+ public void CorrectlyFullyEscapesPaths ( string unescapedPath , string escapedPath )
53
86
{
54
87
string extensionEscapedPath = PowerShellContext . FullyPowerShellEscapePath ( unescapedPath ) ;
55
88
Assert . Equal ( escapedPath , extensionEscapedPath ) ;
@@ -65,6 +98,10 @@ public void CorrectlyFullyEscapesPaths_Spaces(string unescapedPath, string escap
65
98
[ InlineData ( "C:\\ look\\ an`*\\ here.ps1" , "C:\\ look\\ an*\\ here.ps1" ) ]
66
99
[ InlineData ( "/Users/me/Documents/`?here.ps1" , "/Users/me/Documents/?here.ps1" ) ]
67
100
[ InlineData ( "/Brackets` `[and` s`]paces/path.ps1" , "/Brackets [and s]paces/path.ps1" ) ]
101
+ [ InlineData ( "/CJK` chars/脚本/hello.ps1" , "/CJK chars/脚本/hello.ps1" ) ]
102
+ [ InlineData ( "/CJK` chars/脚本/`[hello`].ps1" , "/CJK chars/脚本/[hello].ps1" ) ]
103
+ [ InlineData ( "C:\\ Animal` s\\ утка\\ quack.ps1" , "C:\\ Animal s\\ утка\\ quack.ps1" ) ]
104
+ [ InlineData ( "C:\\ &nimals\\ утка\\ qu`*ck`?.ps1" , "C:\\ &nimals\\ утка\\ qu*ck?.ps1" ) ]
68
105
public void CorrectlyUnescapesPaths ( string escapedPath , string expectedUnescapedPath )
69
106
{
70
107
string extensionUnescapedPath = PowerShellContext . UnescapeGlobEscapedPath ( escapedPath ) ;
0 commit comments