Mirror von
https://github.com/IntellectualSites/FastAsyncWorldEdit.git
synchronisiert 2024-11-09 13:00:05 +01:00
Fix symlink detection.
Dieser Commit ist enthalten in:
Ursprung
4191f017f1
Commit
18414fe3b5
@ -284,12 +284,18 @@ public final class WorldEdit {
|
|||||||
Path filePath = Paths.get(f.toURI()).normalize();
|
Path filePath = Paths.get(f.toURI()).normalize();
|
||||||
Path dirPath = Paths.get(dir.toURI()).normalize();
|
Path dirPath = Paths.get(dir.toURI()).normalize();
|
||||||
|
|
||||||
if (!filePath.startsWith(dirPath)
|
boolean inDir = filePath.startsWith(dirPath);
|
||||||
|| (!getConfiguration().allowSymlinks && !filePath.toRealPath().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");
|
throw new FilenameResolutionException(filename, "Path is outside allowable root");
|
||||||
}
|
}
|
||||||
|
|
||||||
return f;
|
return filePath.toFile();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new FilenameResolutionException(filename, "Failed to resolve path");
|
throw new FilenameResolutionException(filename, "Failed to resolve path");
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren