mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-12-23 09:47:38 +00:00
Fix symlink detection.
This commit is contained in:
parent
4191f017f1
commit
18414fe3b5
@ -284,12 +284,18 @@ public final class WorldEdit {
|
||||
Path filePath = Paths.get(f.toURI()).normalize();
|
||||
Path dirPath = Paths.get(dir.toURI()).normalize();
|
||||
|
||||
if (!filePath.startsWith(dirPath)
|
||||
|| (!getConfiguration().allowSymlinks && !filePath.toRealPath().startsWith(dirPath))) {
|
||||
boolean inDir = filePath.startsWith(dirPath);
|
||||
Path existingParent = filePath;
|
||||
do {
|
||||
existingParent = existingParent.getParent();
|
||||
} while (existingParent != null && !existingParent.toFile().exists());
|
||||
|
||||
boolean isSym = existingParent != null && !existingParent.toRealPath().equals(existingParent);
|
||||
if (!inDir || (!getConfiguration().allowSymlinks && isSym)) {
|
||||
throw new FilenameResolutionException(filename, "Path is outside allowable root");
|
||||
}
|
||||
|
||||
return f;
|
||||
return filePath.toFile();
|
||||
} catch (IOException e) {
|
||||
throw new FilenameResolutionException(filename, "Failed to resolve path");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user