@@ -13,9 +13,12 @@ public class TarArchiveTests
1313 [ Test ]
1414 [ Category ( "Tar" ) ]
1515 [ Category ( "CreatesTempFile" ) ]
16- public void ExtractingContentsWithNonTraversalPathSucceeds ( )
16+ [ TestCase ( "output" ) ]
17+ [ TestCase ( "output/" ) ]
18+ [ TestCase ( @"output\" , IncludePlatform = "Win" ) ]
19+ public void ExtractingContentsWithNonTraversalPathSucceeds ( string outputDir )
1720 {
18- Assert . DoesNotThrow ( ( ) => ExtractTarOK ( "output" , "test-good " , allowTraverse : false ) ) ;
21+ Assert . DoesNotThrow ( ( ) => ExtractTarOK ( outputDir , "file " , allowTraverse : false ) ) ;
1922 }
2023
2124 [ Test ]
@@ -30,12 +33,26 @@ public void ExtractingContentsWithExplicitlyAllowedTraversalPathSucceeds()
3033 [ Category ( "Tar" ) ]
3134 [ Category ( "CreatesTempFile" ) ]
3235 [ TestCase ( "output" , "../file" ) ]
36+ [ TestCase ( "output/" , "../file" ) ]
3337 [ TestCase ( "output" , "../output.txt" ) ]
3438 public void ExtractingContentsWithDisallowedPathsFails ( string outputDir , string fileName )
3539 {
3640 Assert . Throws < InvalidNameException > ( ( ) => ExtractTarOK ( outputDir , fileName , allowTraverse : false ) ) ;
3741 }
3842
43+ [ Test ]
44+ [ Category ( "Tar" ) ]
45+ [ Category ( "CreatesTempFile" ) ]
46+ [ Platform ( Include = "Win" , Reason = "Backslashes are only treated as path separators on windows" ) ]
47+ [ TestCase ( @"output\" , @"..\file" ) ]
48+ [ TestCase ( @"output/" , @"..\file" ) ]
49+ [ TestCase ( "output" , @"..\output.txt" ) ]
50+ [ TestCase ( @"output\" , @"..\output.txt" ) ]
51+ public void ExtractingContentsOnWindowsWithDisallowedPathsFails ( string outputDir , string fileName )
52+ {
53+ Assert . Throws < InvalidNameException > ( ( ) => ExtractTarOK ( outputDir , fileName , allowTraverse : false ) ) ;
54+ }
55+
3956 public void ExtractTarOK ( string outputDir , string fileName , bool allowTraverse )
4057 {
4158 var fileContent = Encoding . UTF8 . GetBytes ( "file content" ) ;
0 commit comments