From: Rainer Jung Date: Fri, 16 Jul 2010 10:36:21 +0000 (+0000) Subject: Merge r960233 from trunk: X-Git-Tag: 2.2.16~16 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=dcbe430f5619c87569294619371d0985b1dfcade;p=thirdparty%2Fapache%2Fhttpd.git Merge r960233 from trunk: mod_rewrite: Allow to set environment variables without explicitely giving a value. Before this patch using [ENV=VAR] instead of [ENV=VAR:VAL] silently drops the flag (it is added to the list of vars to set, but then never actually set). Submitted by: rjung Reviewed by: rjung, niq, rpluem git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.2.x@964741 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/CHANGES b/CHANGES index 5c1dcff3066..3d7aa1b67fe 100644 --- a/CHANGES +++ b/CHANGES @@ -25,6 +25,9 @@ Changes with Apache 2.2.16 an action to happen when a URL maps to no file, without resorting to ErrorDocument or mod_rewrite. PR 47184 [Nick Kew] + *) mod_rewrite: Allow to set environment variables without explicitely + giving a value. [Rainer Jung] + Changes with Apache 2.2.15 diff --git a/STATUS b/STATUS index 9f25c05db9e..ce5d6398e32 100644 --- a/STATUS +++ b/STATUS @@ -86,17 +86,6 @@ RELEASE SHOWSTOPPERS: PATCHES ACCEPTED TO BACKPORT FROM TRUNK: [ start all new proposals below, under PATCHES PROPOSED. ] - *) mod_rewrite: 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. - Currently using [ENV=VAR] instead of [ENV=VAR:VAL] silently drops the flag - (it is added to the list of vars to set, but then never actually set). - Trunk version of patch: - http://svn.apache.org/viewvc?rev=960233&view=rev - Backport version for 2.2.x of patch: - http://people.apache.org/~rjung/patches/httpd-branch-2.2-mod_rewrite-env_var-emptyvalue.patch - +1: rjung, niq, rpluem PATCHES PROPOSED TO BACKPORT FROM TRUNK: [ New proposals should be added at the end of the list ] diff --git a/docs/manual/mod/mod_rewrite.html.en b/docs/manual/mod/mod_rewrite.html.en index 14c881e6fe4..d6fea7b3d53 100644 --- a/docs/manual/mod/mod_rewrite.html.en +++ b/docs/manual/mod/mod_rewrite.html.en @@ -1283,11 +1283,11 @@ cannot use $N in the substitution string! appended.

- 'env|E=VAR:VAL' + 'env|E=VAR[:VAL]' (set environment variable)
This forces an environment variable named VAR to - be set to the value VAL, where VAL can - contain regexp backreferences ($N and + be set. The value will be VAL if provided, where VAL + can contain regexp backreferences ($N and %N) which will be expanded. You can use this flag more than once, to set more than one variable. The variables can later be dereferenced in many situations, most commonly diff --git a/docs/manual/mod/mod_rewrite.xml b/docs/manual/mod/mod_rewrite.xml index d178b1115ca..a9147b96e08 100644 --- a/docs/manual/mod/mod_rewrite.xml +++ b/docs/manual/mod/mod_rewrite.xml @@ -1298,11 +1298,11 @@ cannot use $N in the substitution string! appended.

- 'env|E=VAR:VAL' + 'env|E=VAR[:VAL]' (set environment variable)
This forces an environment variable named VAR to - be set to the value VAL, where VAL can - contain regexp backreferences ($N and + be set. The value will be VAL if provided, where VAL + can contain regexp backreferences ($N and %N) which will be expanded. You can use this flag more than once, to set more than one variable. The variables can later be dereferenced in many situations, most commonly diff --git a/modules/mappers/mod_rewrite.c b/modules/mappers/mod_rewrite.c index fd293e2673e..5b58f5b39da 100644 --- a/modules/mappers/mod_rewrite.c +++ b/modules/mappers/mod_rewrite.c @@ -2349,12 +2349,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; }