rse 98/02/27 06:47:48
Modified: src/modules/standard mod_rewrite.c
Log:
It's unbelievable, it's unbelievable...
We have three locations where one can construct a string in rewriting rules by
expanding $N, %N, %{NAME} and ${map:key}:
- RewriteCond <Location-1> ...
- RewriteRule ... <Location-2> ...
- RewriteRule ... ... [..,E=NAME:<Location-3>,...]
And just after I've added exact comments of what we expand in each location, I
discovered that they are expanded totally inconsequent. For <Location-3> the
%{NAME} and ${map:key} constructs were not expanded (ok, perhaps not really a
%major drawback) and for <Location-1> the ${map:key} construct was not
%expanded while for <Location-2> all are expanded. At least the missing
${map:key} expansion for <Location-1> is horrible because this way we
unnesessarily restricted the usefulness of RewriteCond dramatically.
Perhaps I should add more source comments to mod_rewrite.c
to discover that it then can even can cook a cake now.... ;-)
Revision Changes Path
1.77 +10 -0 apache-1.3/src/modules/standard/mod_rewrite.c
Index: mod_rewrite.c
===================================================================
RCS file: /export/home/cvs/apache-1.3/src/modules/standard/mod_rewrite.c,v
retrieving revision 1.76
retrieving revision 1.77
diff -u -r1.76 -r1.77
--- mod_rewrite.c 1998/02/27 14:31:11 1.76
+++ mod_rewrite.c 1998/02/27 14:47:46 1.77
@@ -1766,6 +1766,10 @@
expand_backref_inbuffer(r->pool, env, sizeof(env), briRR, '$');
/* 3. expand %N (i.e. backrefs to latest RewriteCond pattern)
*/
expand_backref_inbuffer(r->pool, env, sizeof(env), briRC, '%');
+ /* 4. expand %{...} (i.e. variables) */
+ expand_variables_inbuffer(r, env, sizeof(env));
+ /* 5. expand ${...} (RewriteMap lookups) */
+ expand_map_lookups(r, env, sizeof(env));
/* and add the variable to Apache's structures */
add_env_variable(r, env);
}
@@ -1804,6 +1808,10 @@
expand_backref_inbuffer(r->pool, env, sizeof(env), briRR, '$');
/* 3. expand %N (i.e. backrefs to latest RewriteCond pattern) */
expand_backref_inbuffer(r->pool, env, sizeof(env), briRC, '%');
+ /* 4. expand %{...} (i.e. variables) */
+ expand_variables_inbuffer(r, env, sizeof(env));
+ /* 5. expand ${...} (RewriteMap lookups) */
+ expand_map_lookups(r, env, sizeof(env));
/* and add the variable to Apache's structures */
add_env_variable(r, env);
}
@@ -1965,6 +1973,8 @@
expand_backref_inbuffer(r->pool, input, sizeof(input), briRC, '%');
/* 4. expand %{...} (i.e. variables) */
expand_variables_inbuffer(r, input, sizeof(input));
+ /* 5. expand ${...} (RewriteMap lookups) */
+ expand_map_lookups(r, input, sizeof(input));
/*
* Apply the patterns