@@ -88,6 +88,34 @@ public void testNonNormalizedPathRewrite() throws Exception {
8888 doTestRewrite ("RewriteRule ^/b/(.*) /b/../a/$1" , "/b/%255A" , "/b/../a/%255A" );
8989 }
9090
91+ @ Test
92+ public void testChainMatch () throws Exception {
93+ // The first rule matches so the chained (second) rule is applied to the result
94+ doTestRewrite ("RewriteRule ^/a(.*) /b$1 [C]\n " +
95+ "RewriteRule ^/b(.*) /c$1" , "/a/x" , "/c/x" );
96+ }
97+
98+ @ Test
99+ public void testChainHeadNoMatch () throws Exception {
100+ // The first rule does not match so the whole chain, including the
101+ // terminal rule that would otherwise match, must be skipped. If the
102+ // terminal rule were incorrectly applied the request would be rewritten
103+ // to /W/x.
104+ doTestRewrite ("RewriteRule ^/never(.*) /c$1 [C]\n " +
105+ "RewriteRule ^/c(.*) /W$1" , "/c/x" , "/c/x" );
106+ }
107+
108+ @ Test
109+ public void testChainMiddleNoMatch () throws Exception {
110+ // The first rule matches but the second (chained) rule does not, so the
111+ // rest of the chain, including the terminal rule, must be skipped and
112+ // the result of the first rule is retained. If the terminal rule were
113+ // incorrectly applied the request would be rewritten to /W/y.
114+ doTestRewrite ("RewriteRule ^/a(.*) /c$1 [C]\n " +
115+ "RewriteRule ^/nomatch(.*) /x$1 [C]\n " +
116+ "RewriteRule ^/c(.*) /W$1" , "/a/y" , "/c/y" );
117+ }
118+
91119 // BZ 57863
92120 @ Test
93121 public void testRewriteMap01 () throws Exception {
0 commit comments