]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
core: Be explicit if an enclosing directive contains a path or a
authorGraham Leggett <minfrin@apache.org>
Fri, 14 Apr 2023 14:02:11 +0000 (14:02 +0000)
committerGraham Leggett <minfrin@apache.org>
Fri, 14 Apr 2023 14:02:11 +0000 (14:02 +0000)
regex.

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

CHANGES
include/ap_mmn.h
server/core.c

diff --git a/CHANGES b/CHANGES
index 79775ef3f1e0e2aee75584702f1c699b8659bc9e..22f958ab9f60c40f5fae74df6b033fd0880ed5a1 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,9 @@
                                                          -*- coding: utf-8 -*-
 Changes with Apache 2.5.1
 
+  *) core: Be explicit if an enclosing directive contains a path or a
+     regex. [Graham Leggett]
+
   *) mod_http2: fixed a crash during connection termination. See PR 66539.
      [Stefan Eissing]
 
index c0e3116316236b521244f643158a63df5c431c9a..613ebfe10fee6d072f72a85888d0a35f57a28e41 100644 (file)
  * 20211221.9 (2.5.1-dev)  Add additional hcmethod_t enums and PROXY_WORKER_IS_ERROR
  * 20211221.10 (2.5.1-dev) Add ap_proxy_canonenc_ex
  * 20211221.11 (2.5.1-dev) Add AP_CTIME_OPTION_GMTOFF to util_time.h
+ * 20211221.12 (2.5.1-dev) Add cmd_parms->regex
  */
 
 #define MODULE_MAGIC_COOKIE 0x41503235UL /* "AP25" */
 #ifndef MODULE_MAGIC_NUMBER_MAJOR
 #define MODULE_MAGIC_NUMBER_MAJOR 20211221
 #endif
-#define MODULE_MAGIC_NUMBER_MINOR 11             /* 0...n */
+#define MODULE_MAGIC_NUMBER_MINOR 12             /* 0...n */
 
 /**
  * Determine if the server's current MODULE_MAGIC_NUMBER is at least a
index 1e16f03a9e6e859bbd6f0f0c6cf03fbe859fa7de..4c4715c684d3e4fd74ec27e405fd2d4d13b087d5 100644 (file)
@@ -2515,7 +2515,6 @@ 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);
-    ap_regex_t *r = NULL;
     const command_rec *thiscmd = cmd->cmd;
 
     const char *err = ap_check_cmd_context(cmd, NOT_IN_DIR_CONTEXT);
@@ -2538,16 +2537,17 @@ 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)
+        if (!cmd->path) {
             return "<Directory ~ > block must specify a path";
-        r = ap_pregcomp(cmd->pool, cmd->path, AP_REG_EXTENDED|USE_ICASE);
-        if (!r) {
+        }
+        cmd->regex = ap_pregcomp(cmd->pool, cmd->path, AP_REG_EXTENDED|USE_ICASE);
+        if (!cmd->regex) {
             return "Regex could not be compiled";
         }
     }
     else if (thiscmd->cmd_data) { /* <DirectoryMatch> */
-        r = ap_pregcomp(cmd->pool, cmd->path, AP_REG_EXTENDED|USE_ICASE);
-        if (!r) {
+        cmd->regex = ap_pregcomp(cmd->pool, cmd->path, AP_REG_EXTENDED|USE_ICASE);
+        if (!cmd->regex) {
             return "Regex could not be compiled";
         }
     }
@@ -2587,13 +2587,13 @@ static const char *dirsection(cmd_parms *cmd, void *mconfig, const char *arg)
     if (errmsg != NULL)
         return errmsg;
 
-    conf->r = r;
+    conf->r = cmd->regex;
     conf->d = cmd->path;
     conf->d_is_fnmatch = (apr_fnmatch_test(conf->d) != 0);
 
-    if (r) {
+    if (cmd->regex) {
         conf->refs = apr_array_make(cmd->pool, 8, sizeof(char *));
-        ap_regname(r, conf->refs, AP_REG_MATCH, 1);
+        ap_regname(cmd->regex, conf->refs, AP_REG_MATCH, 1);
     }
 
     /* Make this explicit - the "/" root has 0 elements, that is, we
@@ -2625,7 +2625,6 @@ 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;
-    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);
     const char *err = ap_check_cmd_context(cmd, NOT_IN_DIR_CONTEXT);
@@ -2647,15 +2646,15 @@ 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);
-        if (!r) {
+        cmd->regex = ap_pregcomp(cmd->pool, cmd->path, AP_REG_EXTENDED);
+        if (!cmd->regex) {
             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 (!r) {
+        cmd->regex = ap_pregcomp(cmd->pool, cmd->path, AP_REG_EXTENDED);
+        if (!cmd->regex) {
             return "Regex could not be compiled";
         }
     }
@@ -2670,11 +2669,11 @@ static const char *urlsection(cmd_parms *cmd, void *mconfig, const char *arg)
 
     conf->d = apr_pstrdup(cmd->pool, cmd->path);     /* No mangling, please */
     conf->d_is_fnmatch = apr_fnmatch_test(conf->d) != 0;
-    conf->r = r;
+    conf->r = cmd->regex;
 
-    if (r) {
+    if (cmd->regex) {
         conf->refs = apr_array_make(cmd->pool, 8, sizeof(char *));
-        ap_regname(r, conf->refs, AP_REG_MATCH, 1);
+        ap_regname(cmd->regex, conf->refs, AP_REG_MATCH, 1);
     }
 
     ap_add_per_url_conf(cmd->server, new_url_conf);
@@ -2697,7 +2696,6 @@ 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;
-    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);
     const char *err = ap_check_cmd_context(cmd,
@@ -2724,15 +2722,15 @@ 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);
-        if (!r) {
+        cmd->regex = ap_pregcomp(cmd->pool, cmd->path, AP_REG_EXTENDED|USE_ICASE);
+        if (!cmd->regex) {
             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);
-        if (!r) {
+        cmd->regex = ap_pregcomp(cmd->pool, cmd->path, AP_REG_EXTENDED|USE_ICASE);
+        if (!cmd->regex) {
             return "Regex could not be compiled";
         }
     }
@@ -2757,11 +2755,11 @@ static const char *filesection(cmd_parms *cmd, void *mconfig, const char *arg)
 
     conf->d = cmd->path;
     conf->d_is_fnmatch = apr_fnmatch_test(conf->d) != 0;
-    conf->r = r;
+    conf->r = cmd->regex;
 
-    if (r) {
+    if (cmd->regex) {
         conf->refs = apr_array_make(cmd->pool, 8, sizeof(char *));
-        ap_regname(r, conf->refs, AP_REG_MATCH, 1);
+        ap_regname(cmd->regex, conf->refs, AP_REG_MATCH, 1);
     }
 
     ap_add_file_conf(cmd->pool, (core_dir_config *)mconfig, new_file_conf);