summaryrefslogtreecommitdiff
path: root/server
diff options
context:
space:
mode:
authorGraham Leggett <minfrin@apache.org>2022-01-17 16:10:51 +0000
committerGraham Leggett <minfrin@apache.org>2022-01-17 16:10:51 +0000
commitc51dccd833ccaec00df9420701c879ca6fb0e3b4 (patch)
treea2cac77ceb793e94c8e774f0efb2800b611be3fc /server
parent3a286780b19a6022c0d2cafff800586be900b73b (diff)
downloadhttpd-c51dccd833ccaec00df9420701c879ca6fb0e3b4.tar.gz
core: Allow an optional expression to be specified for an effective
path in the DirectoryMatch and LocationMatch directives. This allows modules like mod_dav to map URLs to URL spaces or to directories on the filesystem. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1897156 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'server')
-rw-r--r--server/core.c51
1 files changed, 35 insertions, 16 deletions
diff --git a/server/core.c b/server/core.c
index 67c36f8134..634d4c6b5d 100644
--- a/server/core.c
+++ b/server/core.c
@@ -2506,6 +2506,7 @@ static const char *dirsection(cmd_parms *cmd, void *mconfig, const char *arg)
char *old_path = cmd->path;
core_dir_config *conf;
ap_conf_vector_t *new_dir_conf = ap_create_per_dir_config(cmd->pool);
+ const char *regex;
ap_regex_t *r = NULL;
const command_rec *thiscmd = cmd->cmd;
@@ -2529,15 +2530,20 @@ static const char *dirsection(cmd_parms *cmd, void *mconfig, const char *arg)
if (!strcmp(cmd->path, "~")) {
cmd->path = ap_getword_conf(cmd->pool, &arg);
- if (!cmd->path)
- return "<Directory ~ > block must specify a path";
- r = ap_pregcomp(cmd->pool, cmd->path, AP_REG_EXTENDED|USE_ICASE);
+ if (!*cmd->path) {
+ return "<Directory ~ > block must specify a regex";
+ }
+ regex = ap_getword_conf(cmd->pool, &arg);
+ r = ap_pregcomp(cmd->pool, *regex ? regex : cmd->path,
+ AP_REG_EXTENDED | USE_ICASE);
if (!r) {
return "Regex could not be compiled";
}
}
else if (thiscmd->cmd_data) { /* <DirectoryMatch> */
- r = ap_pregcomp(cmd->pool, cmd->path, AP_REG_EXTENDED|USE_ICASE);
+ regex = ap_getword_conf(cmd->pool, &arg);
+ r = ap_pregcomp(cmd->pool, *regex ? regex : cmd->path,
+ AP_REG_EXTENDED | USE_ICASE);
if (!r) {
return "Regex could not be compiled";
}
@@ -2599,8 +2605,8 @@ static const char *dirsection(cmd_parms *cmd, void *mconfig, const char *arg)
ap_add_per_dir_conf(cmd->server, new_dir_conf);
if (*arg != '\0') {
- return apr_pstrcat(cmd->pool, "Multiple ", thiscmd->name,
- "> arguments not (yet) supported.", NULL);
+ return apr_pstrcat(cmd->pool, "Additional ", thiscmd->name,
+ "> arguments not (yet) supported: ", arg, NULL);
}
cmd->path = old_path;
@@ -2616,6 +2622,7 @@ static const char *urlsection(cmd_parms *cmd, void *mconfig, const char *arg)
int old_overrides = cmd->override;
char *old_path = cmd->path;
core_dir_config *conf;
+ const char *regex;
ap_regex_t *r = NULL;
const command_rec *thiscmd = cmd->cmd;
ap_conf_vector_t *new_url_conf = ap_create_per_dir_config(cmd->pool);
@@ -2638,14 +2645,21 @@ static const char *urlsection(cmd_parms *cmd, void *mconfig, const char *arg)
cmd->override = OR_ALL|ACCESS_CONF;
if (thiscmd->cmd_data) { /* <LocationMatch> */
- r = ap_pregcomp(cmd->pool, cmd->path, AP_REG_EXTENDED);
+ regex = ap_getword_conf(cmd->pool, &arg);
+ r = ap_pregcomp(cmd->pool, *regex ? regex : cmd->path,
+ AP_REG_EXTENDED);
if (!r) {
return "Regex could not be compiled";
}
}
else if (!strcmp(cmd->path, "~")) {
cmd->path = ap_getword_conf(cmd->pool, &arg);
- r = ap_pregcomp(cmd->pool, cmd->path, AP_REG_EXTENDED);
+ if (!*cmd->path) {
+ return "<Location ~ > block must specify a regex";
+ }
+ regex = ap_getword_conf(cmd->pool, &arg);
+ r = ap_pregcomp(cmd->pool, *regex ? regex : cmd->path,
+ AP_REG_EXTENDED);
if (!r) {
return "Regex could not be compiled";
}
@@ -2671,8 +2685,8 @@ static const char *urlsection(cmd_parms *cmd, void *mconfig, const char *arg)
ap_add_per_url_conf(cmd->server, new_url_conf);
if (*arg != '\0') {
- return apr_pstrcat(cmd->pool, "Multiple ", thiscmd->name,
- "> arguments not (yet) supported.", NULL);
+ return apr_pstrcat(cmd->pool, "Additional ", thiscmd->name,
+ "> arguments not (yet) supported: ", arg, NULL);
}
cmd->path = old_path;
@@ -2688,6 +2702,7 @@ static const char *filesection(cmd_parms *cmd, void *mconfig, const char *arg)
int old_overrides = cmd->override;
char *old_path = cmd->path;
core_dir_config *conf;
+ const char *regex;
ap_regex_t *r = NULL;
const command_rec *thiscmd = cmd->cmd;
ap_conf_vector_t *new_file_conf = ap_create_per_dir_config(cmd->pool);
@@ -2715,14 +2730,18 @@ static const char *filesection(cmd_parms *cmd, void *mconfig, const char *arg)
}
if (thiscmd->cmd_data) { /* <FilesMatch> */
- r = ap_pregcomp(cmd->pool, cmd->path, AP_REG_EXTENDED|USE_ICASE);
+ regex = ap_getword_conf(cmd->pool, &arg);
+ r = ap_pregcomp(cmd->pool, *regex ? regex : cmd->path,
+ AP_REG_EXTENDED | USE_ICASE);
if (!r) {
return "Regex could not be compiled";
}
}
else if (!strcmp(cmd->path, "~")) {
cmd->path = ap_getword_conf(cmd->pool, &arg);
- r = ap_pregcomp(cmd->pool, cmd->path, AP_REG_EXTENDED|USE_ICASE);
+ regex = ap_getword_conf(cmd->pool, &arg);
+ r = ap_pregcomp(cmd->pool, *regex ? regex : cmd->path,
+ AP_REG_EXTENDED | USE_ICASE);
if (!r) {
return "Regex could not be compiled";
}
@@ -2758,8 +2777,8 @@ static const char *filesection(cmd_parms *cmd, void *mconfig, const char *arg)
ap_add_file_conf(cmd->pool, (core_dir_config *)mconfig, new_file_conf);
if (*arg != '\0') {
- return apr_pstrcat(cmd->pool, "Multiple ", thiscmd->name,
- "> arguments not (yet) supported.", NULL);
+ return apr_pstrcat(cmd->pool, "Additional ", thiscmd->name,
+ "> arguments not (yet) supported: ", arg, NULL);
}
cmd->path = old_path;
@@ -2845,8 +2864,8 @@ static const char *ifsection(cmd_parms *cmd, void *mconfig, const char *arg)
return errmsg;
if (*arg != '\0') {
- return apr_pstrcat(cmd->pool, "Multiple ", thiscmd->name,
- "> arguments not supported.", NULL);
+ return apr_pstrcat(cmd->pool, "Additional ", thiscmd->name,
+ "> arguments not supported: ", arg, NULL);
}
cmd->path = old_path;