Navigation Menu

Skip to content

Commit

Permalink
[JENKINS-17652] trim quotes from paths before comparing file paths to…
Browse files Browse the repository at this point in the history
… the view paths
  • Loading branch information
Rob Petti committed Apr 25, 2013
1 parent 448fd0a commit 6ed6b70
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/main/java/hudson/plugins/perforce/PerforceSCM.java
Expand Up @@ -1375,6 +1375,10 @@ public static boolean doesFilenameMatchP4Pattern(String filename, String pattern
patternString = patternString.replaceAll("\\*", "[^/]*");
patternString = patternString.replaceAll("\\.\\.\\.", ".*");
patternString = patternString.replaceAll("%%[0-9]", "[^/]*");
patternString = patternString.replaceAll("^\"", "");
patternString = patternString.replaceAll("\"$", "");
filename = filename.replaceAll("^\"", "");
filename = filename.replaceAll("\"$", "");
Pattern pattern = Pattern.compile(patternString, !caseSensitive ? Pattern.CASE_INSENSITIVE : 0);
Matcher matcher = pattern.matcher(filename);
return matcher.matches();
Expand Down
6 changes: 6 additions & 0 deletions src/test/java/hudson/plugins/perforce/PerforceSCMTest.java
Expand Up @@ -279,6 +279,12 @@ public void testFilenameP4PatternMatcher() throws Exception {
assertEquals(false, PerforceSCM.doesFilenameMatchP4Pattern(
"//depot/SomeFile/testFile",
"//depot/%%9", true));
assertEquals(true, PerforceSCM.doesFilenameMatchP4Pattern(
"//depot/Some File/testFile",
"\"//depot/Some File/testFile\"", true));
assertEquals(true, PerforceSCM.doesFilenameMatchP4Pattern(
"\"//depot/Some File/testFile\"",
"//depot/Some File/testFile", true));
}

public void testFileInView() throws Exception {
Expand Down

0 comments on commit 6ed6b70

Please sign in to comment.