]> granicus.if.org Git - apache/commitdiff
Allow to set environment variables using mod_rewrite without
authorRainer Jung <rjung@apache.org>
Sat, 3 Jul 2010 16:21:58 +0000 (16:21 +0000)
committerRainer Jung <rjung@apache.org>
Sat, 3 Jul 2010 16:21:58 +0000 (16:21 +0000)
explicitely giving a value.

Most modules only check presence of a variable, not the
value, so it makes sense to make the VAL argument in
the mod_rewrite ENV flag optional.

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

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

diff --git a/CHANGES b/CHANGES
index a192b6332e2d52649808f4d199e2ef9fc8a9ee9c..19140ae614b909c6983e49542aa2f5ec34a1d102 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -13,6 +13,9 @@ Changes with Apache 2.3.7
 
   *) Fix Windows build when using VC6. [Gregg L. Smith <lists glewis com>]
 
+  *) mod_rewrite: Allow to set environment variables without explicitely
+     giving a value. [Rainer Jung]
+
 Changes with Apache 2.3.6
 
   *) SECURITY: CVE-2009-3555 (cve.mitre.org)
index 12e699cde0e473cce273a87f9ed06f826236ceca..5dac0321af3df0ff93121d9e5487e162e937e1d3 100644 (file)
@@ -920,9 +920,9 @@ 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>Causes an environment variable <em>VAR</em> to be set to the
-        value <em>VAL</em>. <em><a href="../rewrite/flags.html#flag_e">details ...</a></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 href="../rewrite/flags.html#flag_e">details ...</a></em></td>
     </tr>
     <tr>
         <td>forbidden|F</td>
index 08c60ae24965e623a46311bab0ff7f7cd84d3ea4..2fd171487ea0b112c87584de8adf245356cca7e0 100644 (file)
@@ -928,9 +928,9 @@ 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>Causes an environment variable <em>VAR</em> to be set to the
-        value <em>VAL</em>. <em><a
+        <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
         href="../rewrite/flags.html#flag_e">details ...</a></em></td>
     </tr>
     <tr>
index 3f4f8784d76888dffe02ceea36d77d2d1e6f3e74..01506f3c66a46b3bfc24f4fce6fe9c4685411c6b 100644 (file)
@@ -210,7 +210,7 @@ is run, thus unsetting what you have set. See <a href="../env.html">the
 Environment Variables document</a> for more details on how Environment
 variables work.</p>
 
-<p>The syntax for this flag is:</p>
+<p>The full syntax for this flag is:</p>
 
 <div class="example"><p><code>
 [E=VAR:VAL]
@@ -219,7 +219,16 @@ variables work.</p>
 <p><code>VAL</code> may contain backreferences (<code>$N</code> or
 <code>%N</code>) which will be expanded.</p>
 
-<p>These environment variables can then be used in a variety of
+<p>Using the short form</p>
+
+<div class="example"><p><code>
+[E=VAR]
+</code></p></div>
+
+<p>you can set the environment variable named <code>VAR</code> to an
+empty value.</p>
+
+<p>Environment variables can then be used in a variety of
 contexts, including CGI programs, other RewriteRule directives, or
 CustomLog directives.</p>
 
@@ -636,4 +645,4 @@ The <code>L</code> flag can be useful in this context to end the
 </div><div id="footer">
 <p class="apache">Copyright 2010 The Apache Software Foundation.<br />Licensed under the <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>.</p>
 <p class="menu"><a href="../mod/">Modules</a> | <a href="../mod/directives.html">Directives</a> | <a href="../faq/">FAQ</a> | <a href="../glossary.html">Glossary</a> | <a href="../sitemap.html">Sitemap</a></p></div>
-</body></html>
+</body></html>
\ No newline at end of file
index 8c39c01f2a18cbcd26a1cab1f3c561edb82433ba..359259fc14341b97ab6b7d6b47a6ae512883ce50 100644 (file)
@@ -203,7 +203,7 @@ is run, thus unsetting what you have set. See <a href="../env.html">the
 Environment Variables document</a> for more details on how Environment
 variables work.</p>
 
-<p>The syntax for this flag is:</p>
+<p>The full syntax for this flag is:</p>
 
 <example>
 [E=VAR:VAL]
@@ -212,7 +212,16 @@ variables work.</p>
 <p><code>VAL</code> may contain backreferences (<code>$N</code> or
 <code>%N</code>) which will be expanded.</p>
 
-<p>These environment variables can then be used in a variety of
+<p>Using the short form</p>
+
+<example>
+[E=VAR]
+</example>
+
+<p>you can set the environment variable named <code>VAR</code> to an
+empty value.</p>
+
+<p>Environment variables can then be used in a variety of
 contexts, including CGI programs, other RewriteRule directives, or
 CustomLog directives.</p>
 
index b85914ddca8ab876ab2a940b6448d48795972b50..09a1789f9558db729783e0237e08357377156c5f 100644 (file)
@@ -2389,12 +2389,14 @@ static void do_expand_env(data_item *env, rewrite_ctx *ctx)
         name = do_expand(env->data, ctx, NULL);
         if ((val = ap_strchr(name, ':')) != NULL) {
             *val++ = '\0';
-
-            apr_table_set(ctx->r->subprocess_env, name, val);
-            rewritelog((ctx->r, 5, NULL, "setting env variable '%s' to '%s'",
-                        name, val));
+        } else {
+            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;
     }