Skip to content

Commit 60ea5ad

Browse files
daniel-beckzbynek
andauthored
Further limit allowed characters in file path (#686)
* Further limit allowed characters in file path * Apply suggestions from code review Co-authored-by: Zbynek Konecny <[email protected]> --------- Co-authored-by: Daniel Beck <[email protected]> Co-authored-by: Zbynek Konecny <[email protected]>
1 parent 2297112 commit 60ea5ad

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/main/java/io/jenkins/update_center/ArtifactoryRepositoryImpl.java

+7-2
Original file line numberDiff line numberDiff line change
@@ -79,15 +79,20 @@ protected Set<ArtifactCoordinates> listAllJenkinsWars(String groupId) throws IOE
7979
}
8080

8181
private static boolean containsIllegalChars(String test) {
82-
return !test.chars().allMatch(c -> c >= 0x2B && c < 0x7B);
82+
return !test.chars().allMatch(c ->
83+
c >= '0' && c <= '9'
84+
|| c >= 'A' && c <= 'Z'
85+
|| c >= 'a' && c <= 'z'
86+
|| c == '+' || c == '-' || c == '.' || c == '/' || c == '_'
87+
);
8388
}
8489

8590
private static ArtifactCoordinates toGav(JsonFile f) {
8691
String fileName = f.name;
8792
String path = f.path;
8893

8994
if (containsIllegalChars(fileName) || containsIllegalChars(path)) {
90-
LOGGER.log(Level.INFO, "Not only printable ascii: " + f.path + " / " + f.name);
95+
LOGGER.log(Level.INFO, "Characters outside allowed set: " + f.path + " / " + f.name);
9196
return null;
9297
}
9398

0 commit comments

Comments
 (0)