Bug 49512 - PATCH unset environment var with RewriteRule
PATCH unset environment var with RewriteRule
Status: RESOLVED FIXED
Product: Apache httpd-2
Classification: Unclassified
Component: mod_rewrite
2.5-HEAD
PC Linux
: P2 enhancement with 2 votes (vote)
: ---
Assigned To: Apache HTTPD Bugs Mailing List
: FixedInTrunk
Depends on:
Blocks:
  Show dependency tree
 
Reported: 2010-06-28 11:53 UTC by Mark Drayton
Modified: 2012-02-26 17:06 UTC (History)
1 user (show)



Attachments
Unset env vars from RewriteRule (643 bytes, patch)
2010-06-28 11:56 UTC, Mark Drayton
Details | Diff
Unset env vars from RewriteRule (645 bytes, patch)
2010-06-28 12:23 UTC, Mark Drayton
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Mark Drayton 2010-06-28 11:53:57 UTC
We need to unset environment variables from RewriteRules. Attached is a patch against -trunk to do this. Example:

Configuration:

RewriteEngine on
LogLevel rewrite:trace5
RewriteRule ^ - [E=pling:plong]
RewriteRule ^ - [E=foo:boo,E=!pling]

Test:

$ GET http://localhost:8000/cgi-bin/printenv | egrep '(foo|pling)'
foo="boo"

Log:

[Mon Jun 28 16:44:43.364112 2010] [trace2] [pid 516:tid 1153177920] mod_rewrite.c(447): [client 127.0.0.1:44518] 127.0.0.1 - - [localhost/sid#d5c9af8][rid#d6f4680/initial] init rewrite engine with requested uri /cgi-bin/printenv\n
[Mon Jun 28 16:44:43.364157 2010] [trace3] [pid 516:tid 1153177920] mod_rewrite.c(447): [client 127.0.0.1:44518] 127.0.0.1 - - [localhost/sid#d5c9af8][rid#d6f4680/initial] applying pattern '^' to uri '/cgi-bin/printenv'\n
[Mon Jun 28 16:44:43.364177 2010] [trace5] [pid 516:tid 1153177920] mod_rewrite.c(447): [client 127.0.0.1:44518] 127.0.0.1 - - [localhost/sid#d5c9af8][rid#d6f4680/initial] setting env variable 'pling' to 'plong'\n
[Mon Jun 28 16:44:43.364187 2010] [trace3] [pid 516:tid 1153177920] mod_rewrite.c(447): [client 127.0.0.1:44518] 127.0.0.1 - - [localhost/sid#d5c9af8][rid#d6f4680/initial] applying pattern '^' to uri '/cgi-bin/printenv'\n
[Mon Jun 28 16:44:43.364197 2010] [trace5] [pid 516:tid 1153177920] mod_rewrite.c(447): [client 127.0.0.1:44518] 127.0.0.1 - - [localhost/sid#d5c9af8][rid#d6f4680/initial] setting env variable 'foo' to 'boo'\n
[Mon Jun 28 16:44:43.364207 2010] [trace5] [pid 516:tid 1153177920] mod_rewrite.c(447): [client 127.0.0.1:44518] 127.0.0.1 - - [localhost/sid#d5c9af8][rid#d6f4680/initial] unsetting env variable 'pling'\n
[Mon Jun 28 16:44:43.364216 2010] [trace1] [pid 516:tid 1153177920] mod_rewrite.c(447): [client 127.0.0.1:44518] 127.0.0.1 - - [localhost/sid#d5c9af8][rid#d6f4680/initial] pass through /cgi-bin/printenv\n

Obviously this'll be a problem for anyone who is setting environment variables with names starting with !. Hopefully this is uncommon.
Comment 1 Mark Drayton 2010-06-28 11:56:20 UTC
Created attachment 25648 [details]
Unset env vars from RewriteRule
Comment 2 Mark Drayton 2010-06-28 12:23:55 UTC
Created attachment 25649 [details]
Unset env vars from RewriteRule

New patch -- previous was reversed.
Comment 3 Stefan Fritsch 2010-12-29 15:42:27 UTC
Commited with some tweaks to trunk in r1053726
Comment 4 Stefan Fritsch 2012-02-26 17:06:57 UTC
fixed in 2.4.1 and 2.2.20