You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by "Ralf S. Engelschall" <rs...@engelschall.com> on 1997/07/28 19:34:43 UTC
[PATCH] trivial enhancement to RewriteCond patterns
For a lot of mod_rewrite rulesets a rewrite condition like
RewriteRule %{ENV:BLABLA} ^$
and
RewriteRule %{ENV:BLABLA} !^$
is used to check if "BLABLA" is set. This is both complicated to read and has
bad performance. The above patch, which I want to commit to HEAD, makes just a
trivial enhancement to mod_rewrite, so now we can both write
RewriteRule %{ENV:BLABLA} =""
and
RewriteRule %{ENV:BLABLA} !=""
and which also is evaluated more performant.
Ralf S. Engelschall
rse@engelschall.com
www.engelschall.com
Index: mod_rewrite.c
===================================================================
RCS file: /export/home/cvs/apache/src/mod_rewrite.c,v
retrieving revision 1.41
diff -c -r1.41 mod_rewrite.c
*** mod_rewrite.c 1997/07/27 02:10:39 1.41
--- mod_rewrite.c 1997/07/28 17:29:20
***************
*** 1783,1789 ****
rc = (compare_lexicography(input, p->pattern+1) == -1 ? 1 : 0);
}
else if (strlen(p->pattern) > 1 && *(p->pattern) == '=') {
! rc = (strcmp(input, p->pattern+1) == 0 ? 1 : 0);
}
else {
/* it is really a regexp pattern, so apply it */
--- 1783,1792 ----
rc = (compare_lexicography(input, p->pattern+1) == -1 ? 1 : 0);
}
else if (strlen(p->pattern) > 1 && *(p->pattern) == '=') {
! if (strcmp(p->pattern+1, "\"\"") == 0)
! rc = (*input == '\0');
! else
! rc = (strcmp(input, p->pattern+1) == 0 ? 1 : 0);
}
else {
/* it is really a regexp pattern, so apply it */