From 60e8f3a91326e07fea014d315e0ada31627136b5 Mon Sep 17 00:00:00 2001 From: Rainer Jung Date: Sat, 3 Jul 2010 16:21:58 +0000 Subject: [PATCH] Allow to set environment variables using mod_rewrite without 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 | 3 +++ docs/manual/mod/mod_rewrite.html.en | 6 +++--- docs/manual/mod/mod_rewrite.xml | 6 +++--- docs/manual/rewrite/flags.html.en | 15 ++++++++++++--- docs/manual/rewrite/flags.xml | 13 +++++++++++-- modules/mappers/mod_rewrite.c | 10 ++++++---- 6 files changed, 38 insertions(+), 15 deletions(-) diff --git a/CHANGES b/CHANGES index a192b6332e..19140ae614 100644 --- a/CHANGES +++ b/CHANGES @@ -13,6 +13,9 @@ Changes with Apache 2.3.7 *) Fix Windows build when using VC6. [Gregg L. Smith ] + *) 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) diff --git a/docs/manual/mod/mod_rewrite.html.en b/docs/manual/mod/mod_rewrite.html.en index 12e699cde0..5dac0321af 100644 --- a/docs/manual/mod/mod_rewrite.html.en +++ b/docs/manual/mod/mod_rewrite.html.en @@ -920,9 +920,9 @@ cannot use $N in the substitution string! ... - env|E=VAR:VAL - Causes an environment variable VAR to be set to the - value VAL. details ... + env|E=VAR[:VAL] + Causes an environment variable VAR to be set (to the + value VAL if provided). details ... forbidden|F diff --git a/docs/manual/mod/mod_rewrite.xml b/docs/manual/mod/mod_rewrite.xml index 08c60ae249..2fd171487e 100644 --- a/docs/manual/mod/mod_rewrite.xml +++ b/docs/manual/mod/mod_rewrite.xml @@ -928,9 +928,9 @@ cannot use $N in the substitution string! ... - env|E=VAR:VAL - Causes an environment variable VAR to be set to the - value VAL. env|E=VAR[:VAL] + Causes an environment variable VAR to be set (to the + value VAL if provided). details ... diff --git a/docs/manual/rewrite/flags.html.en b/docs/manual/rewrite/flags.html.en index 3f4f8784d7..01506f3c66 100644 --- a/docs/manual/rewrite/flags.html.en +++ b/docs/manual/rewrite/flags.html.en @@ -210,7 +210,7 @@ is run, thus unsetting what you have set. See the Environment Variables document for more details on how Environment variables work.

-

The syntax for this flag is:

+

The full syntax for this flag is:

[E=VAR:VAL] @@ -219,7 +219,16 @@ variables work.

VAL may contain backreferences ($N or %N) which will be expanded.

-

These environment variables can then be used in a variety of +

Using the short form

+ +

+[E=VAR] +

+ +

you can set the environment variable named VAR to an +empty value.

+ +

Environment variables can then be used in a variety of contexts, including CGI programs, other RewriteRule directives, or CustomLog directives.

@@ -636,4 +645,4 @@ The L flag can be useful in this context to end the
- + \ No newline at end of file diff --git a/docs/manual/rewrite/flags.xml b/docs/manual/rewrite/flags.xml index 8c39c01f2a..359259fc14 100644 --- a/docs/manual/rewrite/flags.xml +++ b/docs/manual/rewrite/flags.xml @@ -203,7 +203,7 @@ is run, thus unsetting what you have set. See the Environment Variables document for more details on how Environment variables work.

-

The syntax for this flag is:

+

The full syntax for this flag is:

[E=VAR:VAL] @@ -212,7 +212,16 @@ variables work.

VAL may contain backreferences ($N or %N) which will be expanded.

-

These environment variables can then be used in a variety of +

Using the short form

+ + +[E=VAR] + + +

you can set the environment variable named VAR to an +empty value.

+ +

Environment variables can then be used in a variety of contexts, including CGI programs, other RewriteRule directives, or CustomLog directives.

diff --git a/modules/mappers/mod_rewrite.c b/modules/mappers/mod_rewrite.c index b85914ddca..09a1789f95 100644 --- a/modules/mappers/mod_rewrite.c +++ b/modules/mappers/mod_rewrite.c @@ -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; } -- 2.40.0