Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Further limit allowed characters in file path #686

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,20 @@ protected Set<ArtifactCoordinates> listAllJenkinsWars(String groupId) throws IOE
}

private static boolean containsIllegalChars(String test) {
return !test.chars().allMatch(c -> c >= 0x2B && c < 0x7B);
return !test.chars().allMatch(c ->
c >= 0x30 && c <= 0x39 // allow digits 0-9
|| c >= 0x41 && c <= 0x5A // allows letter A-Z
|| c >= 0x61 && c <= 0x7A // allows letter a-z
|| c == 0x2B || c >= 0x2D && c <= 0x2F || c == 0x5F // allows: +-./_
daniel-beck marked this conversation as resolved.
Show resolved Hide resolved
);
}

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

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

Expand Down