]> granicus.if.org Git - apache/commitdiff
core: Do not match files when using DirectoryMatch. PR41867.
authorJan Kaluža <jkaluza@apache.org>
Thu, 30 Oct 2014 08:34:12 +0000 (08:34 +0000)
committerJan Kaluža <jkaluza@apache.org>
Thu, 30 Oct 2014 08:34:12 +0000 (08:34 +0000)
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1635428 13f79535-47bb-0310-9956-ffa450edef68

include/http_core.h
server/core.c
server/request.c

index 3ed37939c4929974a82f02d22fd343ee2599d61d..85ca580478083a15165c86c196ebb61cde05fe86 100644 (file)
@@ -619,6 +619,7 @@ typedef struct {
 
     unsigned int allow_encoded_slashes_set : 1;
     unsigned int decode_encoded_slashes_set : 1;
+    unsigned int d_is_directory : 1;
 
     /** Named back references */
     apr_array_header_t *refs;
index cca899496f40f49aea236b861801affc5677edf7..ace928ad03267fca6e14390b8c5810eaefc7da29 100644 (file)
@@ -2224,6 +2224,7 @@ static const char *dirsection(cmd_parms *cmd, void *mconfig, const char *arg)
     conf->r = r;
     conf->d = cmd->path;
     conf->d_is_fnmatch = (apr_fnmatch_test(conf->d) != 0);
+    conf->d_is_directory = 1;
 
     if (r) {
         conf->refs = apr_array_make(cmd->pool, 8, sizeof(char *));
index 736c4c444ee81af3ad718eccf065d07b1bcca787..daa2d39fa70a5be4b03e2f745498fc93371bd81c 100644 (file)
@@ -1216,6 +1216,13 @@ AP_DECLARE(int) ap_directory_walk(request_rec *r)
                 pmatch = apr_palloc(rxpool, nmatch*sizeof(ap_regmatch_t));
             }
 
+            /* core_dir_config is Directory*, but the requested file is
+             * not a directory, so although the regexp could match,
+             * we skip it. */
+            if (entry_core->d_is_directory && r->finfo.filetype != APR_DIR) {
+                continue;
+            }
+
             if (ap_regexec(entry_core->r, r->filename, nmatch, pmatch, 0)) {
                 continue;
             }