Always use canonical file path for application folder paths
This commit is contained in:
parent
9dc93cac2b
commit
ba93efa911
|
@ -1,8 +1,13 @@
|
|||
package net.filebot;
|
||||
|
||||
import static net.filebot.Logging.*;
|
||||
import static net.filebot.Settings.*;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.LinkOption;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public enum ApplicationFolder {
|
||||
|
||||
|
@ -15,10 +20,18 @@ public enum ApplicationFolder {
|
|||
|
||||
Cache(System.getProperty("application.cache", AppData.resolve("cache").getPath()));
|
||||
|
||||
private final File path;
|
||||
private File path;
|
||||
|
||||
ApplicationFolder(String path) {
|
||||
this.path = new File(path);
|
||||
try {
|
||||
// use canonical file path
|
||||
this.path = Paths.get(path).toRealPath(LinkOption.NOFOLLOW_LINKS).toFile();
|
||||
} catch (IOException e) {
|
||||
debug.log(Level.WARNING, e, e::toString);
|
||||
|
||||
// default to file path as is
|
||||
this.path = new File(path).getAbsoluteFile();
|
||||
}
|
||||
}
|
||||
|
||||
public File get() {
|
||||
|
|
|
@ -59,7 +59,7 @@ public class SecureCompiledScript extends CompiledScript {
|
|||
|
||||
// write permissions for cache and temp folders
|
||||
for (ApplicationFolder it : ApplicationFolder.values()) {
|
||||
permissions.add(new FilePermission(it.get().getAbsolutePath() + File.separator + "-", "read, write, delete"));
|
||||
permissions.add(new FilePermission(it.get() + File.separator + "-", "read, write, delete"));
|
||||
}
|
||||
|
||||
return permissions;
|
||||
|
|
Loading…
Reference in New Issue