]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
Extend the SetEnvIf directive to capture subexpressions of the
authorAndré Malo <nd@apache.org>
Sun, 15 Aug 2004 23:33:28 +0000 (23:33 +0000)
committerAndré Malo <nd@apache.org>
Sun, 15 Aug 2004 23:33:28 +0000 (23:33 +0000)
matched value.

Reviewed by: Paul J. Reder, Jeff Trawick

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

CHANGES
STATUS
modules/metadata/mod_setenvif.c

diff --git a/CHANGES b/CHANGES
index b25c8fc727d00c85382d5ad0e0dd43d0e65f6f6e..6c46685e832a97822b95cf735a6e079afc520e3a 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,5 +1,8 @@
 Changes with Apache 2.0.51
 
+  *) Extend the SetEnvIf directive to capture subexpressions of the
+     matched value.  [André Malo]
+
   *) Recursive Include directives no longer crash. The server stops
      including configuration files after a certain nesting level (128
      as distributed). This is configurable at compile time using the
diff --git a/STATUS b/STATUS
index 3951bbcfae8419bbf773a84a7b0c5b470a282950..8af9bcada9e649caa71bf7f04f0536afe5e3d46c 100644 (file)
--- a/STATUS
+++ b/STATUS
@@ -1,5 +1,5 @@
 APACHE 2.0 STATUS:                                              -*-text-*-
-Last modified at [$Date: 2004/08/15 22:42:13 $]
+Last modified at [$Date: 2004/08/15 23:33:27 $]
 
 Release:
 
@@ -290,11 +290,6 @@ PATCHES TO BACKPORT FROM 2.1
       -1: brianp (we need a more robust solution than what's in 2.1 right now),
           jerenkrantz (should be fixed, but I don't have time to do this)
 
-    * Extend the SetEnvIf directive to capture subexpressions of the
-      matched value.
-        modules/metadata/mod_setenvif.c r1.42, r1.43
-      +1: nd, rederpj, trawick
-
     * Allow mod_dav to do weak entity comparison functions.
       modules/dav/main/util.c: r1.45
       [ This one is under review.  Don't merge.  ]
index 7608871d1b4fa1bc0f10fa60baacbebcb20676a2..cf33c4806056bad4218eefe864f04764cb3264ad 100644 (file)
@@ -319,8 +319,7 @@ static const char *add_setenvif_core(cmd_parms *cmd, void *mconfig,
         }
         else {
             new->preg = ap_pregcomp(cmd->pool, regex,
-                                    (REG_EXTENDED | REG_NOSUB
-                                     | (icase ? REG_ICASE : 0)));
+                                    (REG_EXTENDED | (icase ? REG_ICASE : 0)));
             if (new->preg == NULL) {
                 return apr_pstrcat(cmd->pool, cmd->cmd->name,
                                    " regex could not be compiled.", NULL);
@@ -458,6 +457,7 @@ static int match_headers(request_rec *r)
     apr_size_t val_len = 0;
     int i, j;
     char *last_name;
+    regmatch_t regm[AP_MAX_REG_MATCH];
 
     if (!ap_get_module_config(r->request_config, &setenvif_module)) {
         ap_set_module_config(r->request_config, &setenvif_module,
@@ -545,7 +545,8 @@ static int match_headers(request_rec *r)
         }
 
         if ((b->pattern && apr_strmatch(b->pattern, val, val_len)) ||
-            (!b->pattern && !ap_regexec(b->preg, val, 0, NULL, 0))) {
+            (!b->pattern && !ap_regexec(b->preg, val, AP_MAX_REG_MATCH, regm,
+                                        0))) {
             const apr_array_header_t *arr = apr_table_elts(b->features);
             elts = (const apr_table_entry_t *) arr->elts;
 
@@ -554,7 +555,18 @@ static int match_headers(request_rec *r)
                     apr_table_unset(r->subprocess_env, elts[j].key);
                 }
                 else {
-                    apr_table_setn(r->subprocess_env, elts[j].key, elts[j].val);
+                    if (!b->pattern) {
+                        char *replaced = ap_pregsub(r->pool, elts[j].val, val,
+                                                    AP_MAX_REG_MATCH, regm);
+                        if (replaced) {
+                            apr_table_setn(r->subprocess_env, elts[j].key,
+                                           replaced);
+                        }
+                    }
+                    else {
+                        apr_table_setn(r->subprocess_env, elts[j].key,
+                                       elts[j].val);
+                    }
                 }
             }
         }