From: markt Date: Sun, 9 Nov 2008 01:35:58 +0000 (+0000) Subject: Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=42673 X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=6529634092d922de1acb4a2428ef2d940fe98bad;p=tomcat7.0 Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=42673 Correctly handle includes with multi-level contexts Patch provided by Peter Jodeleit git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@712461 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/java/org/apache/catalina/ssi/SSIServletExternalResolver.java b/java/org/apache/catalina/ssi/SSIServletExternalResolver.java index fe7dd2a6a..721a84685 100644 --- a/java/org/apache/catalina/ssi/SSIServletExternalResolver.java +++ b/java/org/apache/catalina/ssi/SSIServletExternalResolver.java @@ -353,14 +353,12 @@ public class SSIServletExternalResolver implements SSIExternalResolver { } - protected String getPathWithoutContext(String servletPath) { - String retVal = null; - int secondSlash = servletPath.indexOf('/', 1); - if (secondSlash >= 0) { - //cut off context - retVal = servletPath.substring(secondSlash); + protected String getPathWithoutContext(final String contextPath, + final String servletPath) { + if (servletPath.startsWith(contextPath)) { + return servletPath.substring(contextPath.length()); } - return retVal; + return servletPath; } @@ -419,7 +417,8 @@ public class SSIServletExternalResolver implements SSIExternalResolver { // ie: // '/file1.shtml' vs '/appName1/file1.shtml' if (!isRootContext(normContext)) { - String noContext = getPathWithoutContext(normalized); + String noContext = getPathWithoutContext( + normContext.getContextPath(), normalized); if (noContext == null) { throw new IOException( "Couldn't remove context from path: "