]> granicus.if.org Git - apache/commitdiff
Catch an edge case, where strange subsequent RewriteRules
authorAndré Malo <nd@apache.org>
Tue, 19 Aug 2003 00:52:43 +0000 (00:52 +0000)
committerAndré Malo <nd@apache.org>
Tue, 19 Aug 2003 00:52:43 +0000 (00:52 +0000)
could lead to a 400 (Bad Request) response. Example:

<Directory /path>
    RewriteEngine on
    RewriteBase /
    RewriteRule foo /bar
    RewriteRule bar baz
</Directory>

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

CHANGES
modules/mappers/mod_rewrite.c

diff --git a/CHANGES b/CHANGES
index 0d9ac72615865020f0aa0ad9299bfb90360da520..522976361c3f79548fb305dd6ff97ad3bdd82593 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -2,6 +2,9 @@ Changes with Apache 2.1.0-dev
 
   [Remove entries to the current 2.0 section below, when backported]
 
+  *) mod_rewrite: Catch an edge case, where strange subsequent RewriteRules
+     could lead to a 400 (Bad Request) response.  [André Malo]
+
   *) mod_rewrite: Fix LA-U and LA-F lookups in directory context. Previously
      the current rewrite state was just used as lookup path, which lead to
      strange and often useless results. Related to PR 8493.  [André Malo]
index 932121f8d768b17d37186c964cbd48c1859db850..bb304df8fb35a44fc2582a494a4ed2595e736255 100644 (file)
@@ -3474,7 +3474,6 @@ static int apply_rewrite_rule(request_rec *r, rewriterule_entry *p,
     regex_t *regexp;
     regmatch_t regmatch[MAX_NMATCH];
     exp_ctx *ctx = NULL;
-    int prefixstrip;
     int failed;
     apr_array_header_t *rewriteconds;
     rewritecond_entry *conds;
@@ -3505,14 +3504,12 @@ static int apply_rewrite_rule(request_rec *r, rewriterule_entry *p,
      *  the local part.  Additionally indicate this special
      *  threatment in the logfile.
      */
-    prefixstrip = 0;
-    if (perdir != NULL) {
+    if (perdir) {
         if (   strlen(uri) >= strlen(perdir)
             && strncmp(uri, perdir, strlen(perdir)) == 0) {
             rewritelog((r, 3, perdir, "strip per-dir prefix: %s -> %s",
                         uri, uri+strlen(perdir)));
             uri = uri+strlen(perdir);
-            prefixstrip = 1;
         }
     }
 
@@ -3684,8 +3681,7 @@ static int apply_rewrite_rule(request_rec *r, rewriterule_entry *p,
      *   location, i.e. if it's not an absolute URL (!) path nor
      *   a fully qualified URL scheme.
      */
-    if (prefixstrip && *r->filename != '/'
-                    && !is_absolute_uri(r->filename)) {
+    if (perdir && *r->filename != '/' && !is_absolute_uri(r->filename)) {
         rewritelog((r, 3, perdir, "add per-dir prefix: %s -> %s%s",
                     r->filename, perdir, r->filename));
         r->filename = apr_pstrcat(r->pool, perdir, r->filename, NULL);