Don't unpack WAR files if they are not located in the Host's appBase.
authormarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Fri, 11 Mar 2011 18:40:13 +0000 (18:40 +0000)
committermarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Fri, 11 Mar 2011 18:40:13 +0000 (18:40 +0000)
git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@1080719 13f79535-47bb-0310-9956-ffa450edef68

java/org/apache/catalina/startup/ContextConfig.java
webapps/docs/changelog.xml

index 9b57fe9..129b4a2 100644 (file)
@@ -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);
index 9d0e426..211c49b 100644 (file)
         inside server.xml and log a warning that the configuration has been
         corrected. (markt)
       </add>
+      <fix>
+        Don&apos;t unpack WAR files if they are not located in the Host&apos;s
+        appBase. (markt)
+      </fix>
     </changelog>
   </subsection>
   <subsection name="Other">