Skip to content

Commit

Permalink
Fix replacing of forbidden characters
Browse files Browse the repository at this point in the history
  • Loading branch information
marcphilipp committed Jul 29, 2023
1 parent 40e585b commit fc073e3
Showing 1 changed file with 6 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,15 @@ private synchronized Path resolveRootDir() {
}

private static String sanitizeName(String value) {
StringBuilder result = new StringBuilder();
StringBuilder result = new StringBuilder(value.length());
for (int i = 0; i < value.length(); i++) {
char c = value.charAt(i);
if (!FORBIDDEN_CHARS.contains(c) || Character.isISOControl(c)) {
result.append(c);
}
else {
result.append(REPLACEMENT);
}
result.append(isForbiddenCharacter(c) ? REPLACEMENT : c);
}
return result.toString();
}

private static boolean isForbiddenCharacter(char c) {
return FORBIDDEN_CHARS.contains(c) || Character.isISOControl(c);
}
}

0 comments on commit fc073e3

Please sign in to comment.