From 6ab99b5b156f2eb04f5dc1484950df56f1cc7d3e Mon Sep 17 00:00:00 2001 From: markt Date: Fri, 11 Mar 2011 18:40:13 +0000 Subject: [PATCH] Don't unpack WAR files if they are not located in the Host's appBase. git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@1080719 13f79535-47bb-0310-9956-ffa450edef68 --- java/org/apache/catalina/startup/ContextConfig.java | 13 +++++++------ webapps/docs/changelog.xml | 4 ++++ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/java/org/apache/catalina/startup/ContextConfig.java b/java/org/apache/catalina/startup/ContextConfig.java index 9b57fe9df..129b4a2ee 100644 --- a/java/org/apache/catalina/startup/ContextConfig.java +++ b/java/org/apache/catalina/startup/ContextConfig.java @@ -672,12 +672,6 @@ public class ContextConfig Host host = (Host) context.getParent(); String appBase = host.getAppBase(); - boolean unpackWARs = true; - if (host instanceof StandardHost) { - unpackWARs = ((StandardHost) host).isUnpackWARs() - && ((StandardContext) context).getUnpackWAR(); - } - File canonicalAppBase = new File(appBase); if (canonicalAppBase.isAbsolute()) { canonicalAppBase = canonicalAppBase.getCanonicalFile(); @@ -711,6 +705,13 @@ public class ContextConfig context.getWebappVersion()); String pathName = cn.getBaseName(); + boolean unpackWARs = true; + if (host instanceof StandardHost) { + unpackWARs = ((StandardHost) host).isUnpackWARs() && + ((StandardContext) context).getUnpackWAR() && + (docBase.startsWith(canonicalAppBase.getPath())); + } + if (docBase.toLowerCase(Locale.ENGLISH).endsWith(".war") && !file.isDirectory() && unpackWARs) { URL war = new URL("jar:" + (new File(docBase)).toURI().toURL() + "!/"); docBase = ExpandWar.expand(host, war, pathName); diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml index 9d0e4264f..211c49b9d 100644 --- a/webapps/docs/changelog.xml +++ b/webapps/docs/changelog.xml @@ -50,6 +50,10 @@ inside server.xml and log a warning that the configuration has been corrected. (markt) + + Don't unpack WAR files if they are not located in the Host's + appBase. (markt) + -- 2.11.0