]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
Merge r1724656 from trunk:
authorJim Jagielski <jim@apache.org>
Thu, 21 Jan 2016 16:49:48 +0000 (16:49 +0000)
committerJim Jagielski <jim@apache.org>
Thu, 21 Jan 2016 16:49:48 +0000 (16:49 +0000)
  *) mod_rewrite: Avoid looping on relative substitutions that
     result in the same filename we started with. PR 58854.
     [Eric Covener]

Previously, the comparison of old and new filename happened before
some prefixes might be added.

Submitted by: covener
Reviewed/backported by: jim

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1726016 13f79535-47bb-0310-9956-ffa450edef68

CHANGES
modules/mappers/mod_rewrite.c

diff --git a/CHANGES b/CHANGES
index c9e3a0c99c926d1f54393e15ae2dec67e5fa7d22..f84e92de3fa72fc01102ec6b1266fd39bdc3d9e9 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -2,6 +2,10 @@
 
 Changes with Apache 2.4.19
 
+  *) mod_rewrite: Avoid looping on relative substitutions that
+     result in the same filename we started with. PR 58854.
+     [Eric Covener]
+
   *) mime.types: add common extension "m4a" for MPEG 4 Audio.
      PR 57895 [Dylan Millikin <dylan.millikin gmail.com>]
 
index 8156a7d769158f2e07d40fb9a83c11e8d346347a..70981a0d1a05838473571cbdbc8de884749b5577 100644 (file)
@@ -5010,19 +5010,6 @@ static int hook_fixup(request_rec *r)
                 return HTTP_BAD_REQUEST;
             }
 
-            /* Check for deadlooping:
-             * At this point we KNOW that at least one rewriting
-             * rule was applied, but when the resulting URL is
-             * the same as the initial URL, we are not allowed to
-             * use the following internal redirection stuff because
-             * this would lead to a deadloop.
-             */
-            if (ofilename != NULL && strcmp(r->filename, ofilename) == 0) {
-                rewritelog((r, 1, dconf->directory, "initial URL equal rewritten"
-                            " URL: %s [IGNORING REWRITE]", r->filename));
-                return OK;
-            }
-
             tmpfilename = r->filename;
 
             /* if there is a valid base-URL then substitute
@@ -5083,6 +5070,20 @@ static int hook_fixup(request_rec *r)
                 }
             }
 
+            /* Check for deadlooping:
+             * At this point we KNOW that at least one rewriting
+             * rule was applied, but when the resulting URL is
+             * the same as the initial URL, we are not allowed to
+             * use the following internal redirection stuff because
+             * this would lead to a deadloop.
+             */
+            if (ofilename != NULL && strcmp(r->filename, ofilename) == 0) {
+                rewritelog((r, 1, dconf->directory, "initial URL equal rewritten"
+                            " URL: %s [IGNORING REWRITE]", r->filename));
+                return OK;
+            }
+
+
             /* now initiate the internal redirect */
             rewritelog((r, 1, dconf->directory, "internal redirect with %s "
                         "[INTERNAL REDIRECT]", r->filename));