]> granicus.if.org Git - apache/commitdiff
Extend the SetEnvIf directive to capture subexpressions of the
authorAndré Malo <nd@apache.org>
Fri, 14 Feb 2003 20:04:39 +0000 (20:04 +0000)
committerAndré Malo <nd@apache.org>
Fri, 14 Feb 2003 20:04:39 +0000 (20:04 +0000)
matched value.

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

CHANGES
modules/metadata/mod_setenvif.c

diff --git a/CHANGES b/CHANGES
index 43891fbed6b00fa58511d5d48499d5bd4ceb6094..2a9d220374b3e7b6c3080d98c8291fb93434559b 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -2,6 +2,9 @@ Changes with Apache 2.1.0-dev
 
   [Remove entries to the current 2.0 section below, when backported]
 
+  *) Extend the SetEnvIf directive to capture subexpressions of the
+     matched value.  [André Malo]
+
   *) Updated mod_ldap and mod_auth_ldap to support the Novell LDAP SDK 
      and standardized the LDAP SSL support across the various LDAP SDKs.  
      Isolated the SSL functionality to mod_ldap rather than speading it 
index 37c028d7a118f5b8a62c15d3e3126e61a055ecaf..6b2d033967698c15fa7116a839d5e5d00733743a 100644 (file)
@@ -351,8 +351,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);
@@ -490,6 +489,7 @@ static int match_headers(request_rec *r)
     apr_size_t val_len = 0;
     int i, j;
     char *last_name;
+    regmatch_t regm[10];
 
     if (!ap_get_module_config(r->request_config, &setenvif_module)) {
         ap_set_module_config(r->request_config, &setenvif_module,
@@ -577,7 +577,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, b->preg->re_nsub + 1,
+                                        regm, 0))) {
             const apr_array_header_t *arr = apr_table_elts(b->features);
             elts = (const apr_table_entry_t *) arr->elts;
 
@@ -586,7 +587,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,
+                                                    b->preg->re_nsub + 1, 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);
+                    }
                 }
             }
         }