From 7dd5dc8bf62d4bb01bab11bc4983da00248c2838 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jan=20Kalu=C5=BEa?= Date: Thu, 30 Oct 2014 08:34:12 +0000 Subject: [PATCH] core: Do not match files when using DirectoryMatch. PR41867. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1635428 13f79535-47bb-0310-9956-ffa450edef68 --- include/http_core.h | 1 + server/core.c | 1 + server/request.c | 7 +++++++ 3 files changed, 9 insertions(+) diff --git a/include/http_core.h b/include/http_core.h index 3ed37939c4..85ca580478 100644 --- a/include/http_core.h +++ b/include/http_core.h @@ -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; diff --git a/server/core.c b/server/core.c index cca899496f..ace928ad03 100644 --- a/server/core.c +++ b/server/core.c @@ -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 *)); diff --git a/server/request.c b/server/request.c index 736c4c444e..daa2d39fa7 100644 --- a/server/request.c +++ b/server/request.c @@ -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; } -- 2.40.0