Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=45441
authormarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Wed, 17 Sep 2008 11:11:42 +0000 (11:11 +0000)
committermarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Wed, 17 Sep 2008 11:11:42 +0000 (11:11 +0000)
Filters for INCLUDE/FORWARD need to be matched against servletPath+pathinfo

git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@696240 13f79535-47bb-0310-9956-ffa450edef68

java/org/apache/catalina/core/ApplicationDispatcher.java

index d7225bd..f9b4bba 100644 (file)
@@ -429,7 +429,7 @@ final class ApplicationDispatcher
             if (disInt.intValue() != ApplicationFilterFactory.ERROR) {
                 state.outerRequest.setAttribute
                     (ApplicationFilterFactory.DISPATCHER_REQUEST_PATH_ATTR,
-                     servletPath);
+                     getCombinedPath());
                 state.outerRequest.setAttribute
                     (ApplicationFilterFactory.DISPATCHER_TYPE_ATTR,
                      Integer.valueOf(ApplicationFilterFactory.FORWARD));
@@ -442,7 +442,23 @@ final class ApplicationDispatcher
     }
     
     
-    
+    /**
+     * Combine the servletPath and the pathInfo. If pathInfo is
+     * <code>null</code> it is ignored. If servletPath is <code>null</code> then
+     * <code>null</code> is returned.
+     * @return The combined path with pathInfo appended to servletInfo
+     */
+    private String getCombinedPath() {
+        if (servletPath == null) {
+            return null;
+        }
+        if (pathInfo == null) {
+            return servletPath;
+        }
+        return servletPath + pathInfo;
+    }
+
+
     /**
      * Include the response from another resource in the current response.
      * Any runtime exception, IOException, or ServletException thrown by the
@@ -499,7 +515,7 @@ final class ApplicationDispatcher
                     Integer.valueOf(ApplicationFilterFactory.INCLUDE));
             wrequest.setAttribute(
                     ApplicationFilterFactory.DISPATCHER_REQUEST_PATH_ATTR,
-                    servletPath);
+                    getCombinedPath());
             invoke(state.outerRequest, state.outerResponse, state);
         }
 
@@ -531,7 +547,7 @@ final class ApplicationDispatcher
                     Integer.valueOf(ApplicationFilterFactory.INCLUDE));
             wrequest.setAttribute(
                     ApplicationFilterFactory.DISPATCHER_REQUEST_PATH_ATTR,
-                    servletPath);
+                    getCombinedPath());
             invoke(state.outerRequest, state.outerResponse, state);
         }