From: funkman Date: Sat, 15 Sep 2007 17:42:01 +0000 (+0000) Subject: undo 575332 (alias support) due to 2 vetos X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=76b4757e3039c74a283213032762cd44ee160ad6;p=tomcat7.0 undo 575332 (alias support) due to 2 vetos git-svn-id: https://svn.apache.org/repos/asf/tomcat/tc6.0.x/trunk@575945 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/java/org/apache/naming/resources/FileDirContext.java b/java/org/apache/naming/resources/FileDirContext.java index 033364c73..ddb40feb5 100644 --- a/java/org/apache/naming/resources/FileDirContext.java +++ b/java/org/apache/naming/resources/FileDirContext.java @@ -108,17 +108,6 @@ public class FileDirContext extends BaseDirContext { protected boolean allowLinking = false; - /** - * Aliases - */ - protected String aliases; - - - /** - * Aliases in decoded form. - */ - protected Alias[] pathAliases; - // ------------------------------------------------------------- Properties @@ -134,22 +123,22 @@ public class FileDirContext extends BaseDirContext { */ public void setDocBase(String docBase) { - // Validate the format of the proposed document root - if (docBase == null) - throw new IllegalArgumentException - (sm.getString("resources.null")); + // Validate the format of the proposed document root + if (docBase == null) + throw new IllegalArgumentException + (sm.getString("resources.null")); - // Calculate a File object referencing this document base directory - base = new File(docBase); + // Calculate a File object referencing this document base directory + base = new File(docBase); try { base = base.getCanonicalFile(); } catch (IOException e) { // Ignore } - // Validate that the document base is an existing directory - if (!base.exists() || !base.isDirectory() || !base.canRead()) - throw new IllegalArgumentException + // Validate that the document base is an existing directory + if (!base.exists() || !base.isDirectory() || !base.canRead()) + throw new IllegalArgumentException (sm.getString("fileResources.base", docBase)); this.absoluteBase = base.getAbsolutePath(); super.setDocBase(docBase); @@ -188,69 +177,18 @@ public class FileDirContext extends BaseDirContext { return allowLinking; } - /** - * Get the alias string in use. - */ - public String getAliases(String aliases) { - return aliases; - } + + // --------------------------------------------------------- Public Methods /** - * Set files system aliases. Aliases are of the form - *
prefix=path,prefix2=path2
- * For example: - *
-     *   /images/=/tmp/images/,
-     *   /pdf/=/usr/local/data/pdfs/
-     * 
+ * Release any resources allocated for this directory context. */ - public void setAliases(String aliases) { - this.aliases = aliases; - - pathAliases = null; - if (this.aliases!=null) { - this.aliases = this.aliases.trim(); - } - if (this.aliases==null||this.aliases.length()==0) { - this.aliases=null; - return; - } - - String[] split1 = this.aliases.split(","); - ArrayList aliasList = new ArrayList(); - for (int i=0; split1!=null && i0 && kvp[1].length()>0) { - Alias alias = new Alias(); - alias.prefix=kvp[0]; - alias.basePath= new File(kvp[1]); - alias.absPath=alias.basePath.getAbsolutePath(); - aliasList.add(alias); - } - } - } - - if (aliasList.size()>0) { - pathAliases = new Alias[aliasList.size()]; - for (int i=0; i= 0) - normalized = normalized.replace('\\', '/'); - if (!normalized.startsWith("/")) - normalized = "/" + normalized; - - // Resolve occurrences of "//" in the normalized path - while (true) { - int index = normalized.indexOf("//"); - if (index < 0) - break; - normalized = normalized.substring(0, index) + - normalized.substring(index + 1); - } + String normalized = path; + + // Normalize the slashes and add leading slash if necessary + if (File.separatorChar == '\\' && normalized.indexOf('\\') >= 0) + normalized = normalized.replace('\\', '/'); + if (!normalized.startsWith("/")) + normalized = "/" + normalized; + + // Resolve occurrences of "//" in the normalized path + while (true) { + int index = normalized.indexOf("//"); + if (index < 0) + break; + normalized = normalized.substring(0, index) + + normalized.substring(index + 1); + } - // Resolve occurrences of "/./" in the normalized path - while (true) { - int index = normalized.indexOf("/./"); - if (index < 0) - break; - normalized = normalized.substring(0, index) + - normalized.substring(index + 2); - } + // Resolve occurrences of "/./" in the normalized path + while (true) { + int index = normalized.indexOf("/./"); + if (index < 0) + break; + normalized = normalized.substring(0, index) + + normalized.substring(index + 2); + } - // Resolve occurrences of "/../" in the normalized path - while (true) { - int index = normalized.indexOf("/../"); - if (index < 0) - break; - if (index == 0) - return (null); // Trying to go outside our context - int index2 = normalized.lastIndexOf('/', index - 1); - normalized = normalized.substring(0, index2) + - normalized.substring(index + 3); - } + // Resolve occurrences of "/../" in the normalized path + while (true) { + int index = normalized.indexOf("/../"); + if (index < 0) + break; + if (index == 0) + return (null); // Trying to go outside our context + int index2 = normalized.lastIndexOf('/', index - 1); + normalized = normalized.substring(0, index2) + + normalized.substring(index + 3); + } - // Return the normalized path that we have completed - return (normalized); + // Return the normalized path that we have completed + return (normalized); } @@ -928,27 +818,12 @@ public class FileDirContext extends BaseDirContext { */ protected File file(String name) { - File baseDir = base; - String absoluteBaseDir = absoluteBase; - - if (pathAliases!=null) { - for (int i=0; i - - Allow for aliases in FileDirContext. (funkman) -