Fix potential stackoverflow for normalized files

This commit is contained in:
crschnick
2025-04-29 15:27:22 +00:00
parent c87aaab9d7
commit 80a81eafe4
@@ -9,9 +9,9 @@ import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.regex.Pattern;
@EqualsAndHashCode
public final class FilePath {
public static boolean isProbableFilePath(OsType osType, String s) {
@@ -45,6 +45,20 @@ public final class FilePath {
}
}
@Override
public boolean equals(Object o) {
if (o == null || getClass() != o.getClass()) {
return false;
}
FilePath filePath = (FilePath) o;
return Objects.equals(value, filePath.value);
}
@Override
public int hashCode() {
return Objects.hashCode(value);
}
public FilePath fileSystemCompatible(OsType osType) {
var split = split();
var needsReplacement = split.stream().anyMatch(s -> !s.equals(osType.makeFileSystemCompatible(s)));