]> granicus.if.org Git - apache/commitdiff
Allow to unset environment variables using E=!VAR.
authorStefan Fritsch <sf@apache.org>
Wed, 29 Dec 2010 20:41:55 +0000 (20:41 +0000)
committerStefan Fritsch <sf@apache.org>
Wed, 29 Dec 2010 20:41:55 +0000 (20:41 +0000)
PR: 49512
Submitted by: Mark Drayton <mark markdrayton info>, Stefan Fritsch

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

CHANGES
docs/manual/mod/mod_rewrite.xml
docs/manual/rewrite/flags.xml
modules/mappers/mod_rewrite.c

diff --git a/CHANGES b/CHANGES
index 44dba865b3976b3d0021e89879d6c79676179665..9f1e631b430c90d7a68351b0c6a86adfd4bf7939 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -2,6 +2,9 @@
 
 Changes with Apache 2.3.11
 
+  *) mod_rewrite: Allow to unset environment variables using E=!VAR.
+     PR 49512. [Mark Drayton <mark markdrayton info>, Stefan Fritsch]
+
   *) mod_headers: Restore the 2.3.8 and earlier default for the first 
      argument of the Header directive ("onsuccess").  [Eric Covener]
 
index 4896f4dcfadec9ff1733c53c0a2b8af533a8c274..d219cda527f664597ca369c1d0b24e5f0e01647a 100644 (file)
@@ -1036,9 +1036,10 @@ cannot use <code>$N</code> in the substitution string!
         ...</a></em></td>
     </tr>
     <tr>
-        <td>env|E=<em>VAR</em>[:<em>VAL</em>]</td>
+        <td>env|E=[!]<em>VAR</em>[:<em>VAL</em>]</td>
         <td>Causes an environment variable <em>VAR</em> to be set (to the
-        value <em>VAL</em> if provided). <em><a
+        value <em>VAL</em> if provided). The form !<em>VAR</em> causes
+        the environment variable <em>VAR</em> to be unset.<em><a
         href="../rewrite/flags.html#flag_e">details ...</a></em></td>
     </tr>
     <tr>
index c36978ebdab4977afced53cb2f5e98bbb454b5c7..7457b7853b50759c3bfc10ef0a2a6ce4831a022d 100644 (file)
@@ -212,6 +212,7 @@ variables work.</p>
 
 <example>
 [E=VAR:VAL]
+[E=!VAR]
 </example>
 
 <p><code>VAL</code> may contain backreferences (<code>$N</code> or
@@ -226,6 +227,15 @@ variables work.</p>
 <p>you can set the environment variable named <code>VAR</code> to an
 empty value.</p>
 
+<p>The form</p>
+
+<example>
+[E=!VAR]
+</example>
+
+<p>allows to unset a previouslz set environment variable named
+<code>VAR</code>.</p>
+
 <p>Environment variables can then be used in a variety of
 contexts, including CGI programs, other RewriteRule directives, or
 CustomLog directives.</p>
index 44ff0b46cc54199796e60b9cfe2dab55346c0ba2..2571e2ca840ed8743cc5e6d4595747cc6da28f30 100644 (file)
@@ -2408,15 +2408,22 @@ static void do_expand_env(data_item *env, rewrite_ctx *ctx)
 
     while (env) {
         name = do_expand(env->data, ctx, NULL);
-        if ((val = ap_strchr(name, ':')) != NULL) {
-            *val++ = '\0';
-        } else {
-            val = "";
+        if (*name == '!') {
+            name++;
+            apr_table_unset(ctx->r->subprocess_env, name);
+            rewritelog((ctx->r, 5, NULL, "unsetting env variable '%s'", name));
         }
+        else {
+            if ((val = ap_strchr(name, ':')) != NULL) {
+                *val++ = '\0';
+            } else {
+                val = "";
+            }
 
-        apr_table_set(ctx->r->subprocess_env, name, val);
-        rewritelog((ctx->r, 5, NULL, "setting env variable '%s' to '%s'",
-                    name, val));
+            apr_table_set(ctx->r->subprocess_env, name, val);
+            rewritelog((ctx->r, 5, NULL, "setting env variable '%s' to '%s'",
+                        name, val));
+        }
 
         env = env->next;
     }