This repository has been archived by the owner on Nov 19, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 132
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Federico Pellegrin <fede@evolware.org>
- Loading branch information
1 parent
fdee535
commit ea41b3f
Showing
4 changed files
with
96 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package hudson.plugins.cobertura; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
import org.junit.Test; | ||
|
||
public class IOUtilsTest { | ||
|
||
@Test | ||
public void testSanitizeRelativePathInUnix() { | ||
String fileName = "../aaa/bbb"; | ||
String sanitizedName = IOUtils.sanitizeFilename(fileName); | ||
|
||
assertEquals("_2e_2e_2faaa_2fbbb", sanitizedName); | ||
|
||
fileName = "aaa/../bbb"; | ||
sanitizedName = IOUtils.sanitizeFilename(fileName); | ||
|
||
assertEquals("aaa_2f_2e_2e_2fbbb", sanitizedName); | ||
} | ||
|
||
@Test | ||
public void testSanitizeRelativePathInWindows() { | ||
String fileName = "..\\aaa\\bbb"; | ||
String sanitizedName = IOUtils.sanitizeFilename(fileName); | ||
|
||
assertEquals("_2e_2e_5caaa_5cbbb", sanitizedName); | ||
|
||
fileName = "aaa\\..\\bbb"; | ||
sanitizedName = IOUtils.sanitizeFilename(fileName); | ||
assertEquals( "aaa_5c_2e_2e_5cbbb", sanitizedName); | ||
} | ||
|
||
|
||
@Test | ||
public void testSanitizeAbsolutePathInUnix() { | ||
String fileName = "/aaa/bbb"; | ||
String sanitizedFileName = IOUtils.sanitizeFilename(fileName); | ||
|
||
assertEquals("_2faaa_2fbbb", sanitizedFileName); | ||
} | ||
|
||
@Test | ||
public void testSanitizeAbsolutePathInWindows() { | ||
String fileName = "C:\\aaa\\bbb"; | ||
String sanitizedName = IOUtils.sanitizeFilename(fileName); | ||
|
||
assertEquals("C_3a_5caaa_5cbbb", sanitizedName); | ||
} | ||
} |