]> granicus.if.org Git - apache/commitdiff
Add a "MATCH_" prefix to variables set within
authorGraham Leggett <minfrin@apache.org>
Fri, 3 Jan 2014 22:26:55 +0000 (22:26 +0000)
committerGraham Leggett <minfrin@apache.org>
Fri, 3 Jan 2014 22:26:55 +0000 (22:26 +0000)
LocationMatch/DirectoryMatch/FilesMatch.

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

docs/manual/mod/core.xml
docs/manual/mod/mod_proxy.xml
include/ap_regex.h
modules/proxy/mod_proxy.c
server/core.c
server/util_pcre.c

index 6e3c2ff9c8006b213bf1d3d2debdbf170b774f79..0fdbdd63a38de77fe8e23625dc7387e5da199273 100644 (file)
@@ -887,15 +887,15 @@ the contents of file-system directories matching a regular expression.</descript
     </note>
 
     <p>From 2.5.0 onwards, named groups and backreferences are captured and
-    written to the environment with the corresponding name in upper case.
-    This allows elements of paths to be referenced from within
-    <a href="expr.html">expressions</a> and modules like
+    written to the environment with the corresponding name prefixed with
+    "MATCH_" and in upper case. This allows elements of paths to be referenced
+    from within <a href="expr.html">expressions</a> and modules like
     <module>mod_rewrite</module>. In order to prevent confusion, numbered
     (unnamed) backreferences are ignored. Use named groups instead.</p>
 
 <highlight language="config">
-&lt;DirectoryMatch ^/var/www/combined/(?&lt;SITENAME&gt;[^/]+)&gt;
-    require ldap-group cn=%{env:SITENAME},ou=combined,o=Example
+&lt;DirectoryMatch ^/var/www/combined/(?&lt;sitename&gt;[^/]+)&gt;
+    require ldap-group cn=%{env:MATCH_SITENAME},ou=combined,o=Example
 &lt;/DirectoryMatch&gt;
 </highlight>
 </usage>
@@ -1750,15 +1750,15 @@ filenames</description>
     <p>would match most common Internet graphics formats.</p>
 
     <p>From 2.5.0 onwards, named groups and backreferences are captured and
-    written to the environment with the corresponding name in upper case.
-    This allows elements of files to be referenced from within
-    <a href="expr.html">expressions</a> and modules like
+    written to the environment with the corresponding name prefixed with
+    "MATCH_" and in upper case. This allows elements of files to be referenced
+    from within <a href="expr.html">expressions</a> and modules like
     <module>mod_rewrite</module>. In order to prevent confusion, numbered
     (unnamed) backreferences are ignored. Use named groups instead.</p>
 
 <highlight language="config">
-&lt;FileMatch ^(?&lt;SITENAME&gt;[^/]+)&gt;
-    require ldap-group cn=%{env:SITENAME},ou=combined,o=Example
+&lt;FileMatch ^(?&lt;sitename&gt;[^/]+)&gt;
+    require ldap-group cn=%{env:MATCH_SITENAME},ou=combined,o=Example
 &lt;/FileMatch&gt;
 </highlight>
 </usage>
@@ -2716,15 +2716,15 @@ matching URLs</description>
     or <code>/special/data</code>.</p>
 
     <p>From 2.5.0 onwards, named groups and backreferences are captured and
-    written to the environment with the corresponding name in upper case.
-    This allows elements of URLs to be referenced from within
-    <a href="expr.html">expressions</a> and modules like
+    written to the environment with the corresponding name prefixed with
+    "MATCH_" and in upper case. This allows elements of URLs to be referenced
+    from within <a href="expr.html">expressions</a> and modules like
     <module>mod_rewrite</module>. In order to prevent confusion, numbered
     (unnamed) backreferences are ignored. Use named groups instead.</p>
 
 <highlight language="config">
-&lt;LocationMatch ^/combined/(?&lt;SITENAME&gt;[^/]+)&gt;
-    require ldap-group cn=%{env:SITENAME},ou=combined,o=Example
+&lt;LocationMatch ^/combined/(?&lt;sitename&gt;[^/]+)&gt;
+    require ldap-group cn=%{env:MATCH_SITENAME},ou=combined,o=Example
 &lt;/LocationMatch&gt;
 </highlight>
 </usage>
index cbec7740052674e25f87fb5f28c2467a7fcd9a5a..8338c2f2c1f3023a154cef8abfc29b57e97808bf 100644 (file)
@@ -530,15 +530,15 @@ proxied resources</description>
     using <glossary ref="regex">regular expressions</glossary>.</p>
 
     <p>From 2.5.0 onwards, named groups and backreferences are captured and
-    written to the environment with the corresponding name in upper case.
-    This allows elements of URLs to be referenced from within
-    <a href="expr.html">expressions</a> and modules like
+    written to the environment with the corresponding name prefixed with
+    "MATCH_" and in upper case. This allows elements of URLs to be referenced
+    from within <a href="expr.html">expressions</a> and modules like
     <module>mod_rewrite</module>. In order to prevent confusion, numbered
     (unnamed) backreferences are ignored. Use named groups instead.</p>
 
 <highlight language="config">
-&lt;ProxyMatch ^http://(?&lt;SITENAME&gt;[^/]+)&gt;
-    require ldap-group cn=%{env:SITENAME},ou=combined,o=Example
+&lt;ProxyMatch ^http://(?&lt;sitename&gt;[^/]+)&gt;
+    require ldap-group cn=%{env:MATCH_SITENAME},ou=combined,o=Example
 &lt;/ProxyMatch&gt;
 </highlight>
 </usage>
index 8f0aedd322c12f0273d7fb94d2d2b66c0d3e31b5..be41226beef768d5702d641bfed04389db4f0b0f 100644 (file)
@@ -77,6 +77,8 @@ extern "C" {
 #define AP_REG_NOMEM 0x20    /* nomem in our code */
 #define AP_REG_DOTALL 0x40   /* perl's /s flag */
 
+#define AP_REG_MATCH "MATCH_" /** suggested prefix for ap_regname */
+
 /* Error values: */
 enum {
   AP_REG_ASSERT = 1,  /** internal error ? */
@@ -156,7 +158,8 @@ AP_DECLARE(apr_size_t) ap_regerror(int errcode, const ap_regex_t *preg,
  * @param upper If non zero, uppercase the names
  */
 AP_DECLARE(int) ap_regname(const ap_regex_t *preg,
-                           apr_array_header_t *names, int upper);
+                           apr_array_header_t *names, const char *prefix,
+                           int upper);
 
 /** Destroy a pre-compiled regex.
  * @param preg The pre-compiled regex to free.
index d0bc8c79a5e0b19bf4974ad3f82b9b337ef90bb4..9279cc81afc6d6d43613b5b077235ceb548afb49 100644 (file)
@@ -2275,7 +2275,7 @@ static const char *proxysection(cmd_parms *cmd, void *mconfig, const char *arg)
 
     if (r) {
         conf->refs = apr_array_make(cmd->pool, 8, sizeof(char *));
-        ap_regname(r, conf->refs, 1);
+        ap_regname(r, conf->refs, AP_REG_MATCH, 1);
     }
 
     ap_add_per_proxy_conf(cmd->server, new_dir_conf);
index f7bef0fe0959edea8a94e184e539d932397f1d67..ff7c43dce0e303bb85cd6d712b92d7a9e4400fda 100644 (file)
@@ -2223,7 +2223,7 @@ static const char *dirsection(cmd_parms *cmd, void *mconfig, const char *arg)
 
     if (r) {
         conf->refs = apr_array_make(cmd->pool, 8, sizeof(char *));
-        ap_regname(r, conf->refs, 1);
+        ap_regname(r, conf->refs, AP_REG_MATCH, 1);
     }
 
     /* Make this explicit - the "/" root has 0 elements, that is, we
@@ -2304,7 +2304,7 @@ static const char *urlsection(cmd_parms *cmd, void *mconfig, const char *arg)
 
     if (r) {
         conf->refs = apr_array_make(cmd->pool, 8, sizeof(char *));
-        ap_regname(r, conf->refs, 1);
+        ap_regname(r, conf->refs, AP_REG_MATCH, 1);
     }
 
     ap_add_per_url_conf(cmd->server, new_url_conf);
@@ -2391,7 +2391,7 @@ static const char *filesection(cmd_parms *cmd, void *mconfig, const char *arg)
 
     if (r) {
         conf->refs = apr_array_make(cmd->pool, 8, sizeof(char *));
-        ap_regname(r, conf->refs, 1);
+        ap_regname(r, conf->refs, AP_REG_MATCH, 1);
     }
 
     ap_add_file_conf(cmd->pool, (core_dir_config *)mconfig, new_file_conf);
index 41761487e42667443a5f128f7af3da886a876a6f..4d2adef25b67d20f430a568808d2d5eca5ccbd5c 100644 (file)
@@ -258,7 +258,8 @@ AP_DECLARE(int) ap_regexec_len(const ap_regex_t *preg, const char *buff,
 }
 
 AP_DECLARE(int) ap_regname(const ap_regex_t *preg,
-                           apr_array_header_t *names, int upper)
+                           apr_array_header_t *names, const char *prefix,
+                           int upper)
 {
     int namecount;
     int nameentrysize;
@@ -278,10 +279,14 @@ AP_DECLARE(int) ap_regname(const ap_regex_t *preg,
         while (names->nelts <= capture) {
             apr_array_push(names);
         }
-        if (upper) {
-            char *name = ((char **)names->elts)[capture] = 
-                apr_pstrdup(names->pool, offset + 2);
-            ap_str_toupper(name);
+        if (upper || prefix) {
+            char *name = ((char **) names->elts)[capture] =
+                    prefix ? apr_pstrcat(names->pool, prefix, offset + 2,
+                            NULL) :
+                            apr_pstrdup(names->pool, offset + 2);
+            if (upper) {
+                ap_str_toupper(name);
+            }
         }
         else {
             ((const char **)names->elts)[capture] = offset + 2;