From a54c7437fc8e4854c9ffeadc0e775fd98a094133 Mon Sep 17 00:00:00 2001 From: Wizjany Date: Tue, 25 Dec 2012 18:08:03 -0500 Subject: [PATCH] Add config option to allow symbolic links for files. --- src/main/java/com/sk89q/worldedit/LocalConfiguration.java | 1 + src/main/java/com/sk89q/worldedit/WorldEdit.java | 2 +- .../java/com/sk89q/worldedit/util/YAMLConfiguration.java | 2 ++ src/main/resources/config.yml | 6 +++++- 4 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/sk89q/worldedit/LocalConfiguration.java b/src/main/java/com/sk89q/worldedit/LocalConfiguration.java index e81c3c724..03ddc508a 100644 --- a/src/main/java/com/sk89q/worldedit/LocalConfiguration.java +++ b/src/main/java/com/sk89q/worldedit/LocalConfiguration.java @@ -107,6 +107,7 @@ public abstract class LocalConfiguration { public int butcherDefaultRadius = -1; public int butcherMaxRadius = -1; public boolean allowExtraDataValues = false; + public boolean allowSymlinks = false; /** * Loads the configuration. diff --git a/src/main/java/com/sk89q/worldedit/WorldEdit.java b/src/main/java/com/sk89q/worldedit/WorldEdit.java index 917ddb63b..2f4a4017d 100644 --- a/src/main/java/com/sk89q/worldedit/WorldEdit.java +++ b/src/main/java/com/sk89q/worldedit/WorldEdit.java @@ -825,7 +825,7 @@ public class WorldEdit { String filePath = f.getCanonicalPath(); String dirPath = dir.getCanonicalPath(); - if (!filePath.substring(0, dirPath.length()).equals(dirPath)) { + if (!filePath.substring(0, dirPath.length()).equals(dirPath) && !config.allowSymlinks) { throw new FilenameResolutionException(filename, "Path is outside allowable root"); } diff --git a/src/main/java/com/sk89q/worldedit/util/YAMLConfiguration.java b/src/main/java/com/sk89q/worldedit/util/YAMLConfiguration.java index fffc90ccb..6c5aacaf3 100644 --- a/src/main/java/com/sk89q/worldedit/util/YAMLConfiguration.java +++ b/src/main/java/com/sk89q/worldedit/util/YAMLConfiguration.java @@ -93,6 +93,8 @@ public class YAMLConfiguration extends LocalConfiguration { saveDir = config.getString("saving.dir", saveDir); + allowSymlinks = config.getBoolean("files.allow-symbolic-links", false); + disallowedBlocks = new HashSet(config.getIntList("limits.disallowed-blocks", null)); allowedDataCycleBlocks = new HashSet(config.getIntList("limits.allowed-data-cycle-blocks", null)); diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 05227d5ff..482937fd2 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -16,6 +16,7 @@ # limits: + allow-extra-data-values: false max-blocks-changed: default: -1 maximum: -1 @@ -56,10 +57,13 @@ scripting: saving: dir: schematics +files: + allow-symbolic-links: false + history: size: 15 expiration: 10 - + wand-item: 271 shell-save-type: no-double-slash: false