]> granicus.if.org Git - apache/commitdiff
Ignore RewriteRules in .htaccess files if the directory
authorAndré Malo <nd@apache.org>
Tue, 15 Jul 2003 17:49:03 +0000 (17:49 +0000)
committerAndré Malo <nd@apache.org>
Tue, 15 Jul 2003 17:49:03 +0000 (17:49 +0000)
containing the .htaccess file is requested without a trailing slash.

PR: 20195

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

CHANGES
modules/mappers/mod_rewrite.c

diff --git a/CHANGES b/CHANGES
index e5dc5ecb95d553dc0cd6fce77774ae19a778a11d..cb66f7628ad075be007bd042973625e36f88de8c 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -2,6 +2,10 @@ Changes with Apache 2.1.0-dev
 
   [Remove entries to the current 2.0 section below, when backported]
 
+  *) mod_rewrite: Ignore RewriteRules in .htaccess files if the directory
+     containing the .htaccess file is requested without a trailing slash.
+     PR 20195.  [André Malo]
+
   *) mod_autoindex: If a directory contains a file listed in the
      DirectoryIndex directive, the folder icon is no longer replaced
      by the icon of that file. PR 9587.
index 32066f4c368362bd524083b169b7a6a2c2cd54b9..2d673bb825d984674a7ac6bb4029257dbe62c238 100644 (file)
@@ -1443,6 +1443,18 @@ static int hook_fixup(request_rec *r)
         return DECLINED;
     }
 
+    /*
+     *  .htaccess file is called before really entering the directory, i.e.:
+     *  URL: http://localhost/foo  and .htaccess is located in foo directory
+     *  Ignore such attempts, since they may lead to undefined behaviour.
+     */
+    if (r->filename &&
+        strlen(r->filename) == strlen(dconf->directory) - 1 &&
+        (dconf->directory)[strlen(dconf->directory) - 1] == '/' &&
+        !strncmp(r->filename, dconf->directory, strlen(dconf->directory) - 1)) {
+        return DECLINED;
+    }
+
     /*
      *  only do something under runtime if the engine is really enabled,
      *  for this directory, else return immediately!