www-apache-bugdb mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Matt Hoskins <m...@nipltd.com>
Subject mod_rewrite/4161: $0 can't be used in the substitution if there are no subexpressions
Date Mon, 29 Mar 1999 12:27:40 GMT

>Number:         4161
>Category:       mod_rewrite
>Synopsis:       $0 can't be used in the substitution if there are no subexpressions
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    apache
>State:          open
>Class:          sw-bug
>Submitter-Id:   apache
>Arrival-Date:   Mon Mar 29 04:30:01 PST 1999
>Originator:     matt@nipltd.com
>Release:        1.3.6
SunOS 5.5.1
In the function expand_backref_inbuffer in mod_rewrite.c the function has:
if(bri->nsub<1) {

I suspect this is put in as an optimisation to mean that if there are no
subexpressions in the pattern, don't bother trying to substitute in back
references. However this means if you have a pattern with no subexpressions and
wish to use $0 in the substitution, you just get "$0" dumped straight in.

This is of course trivial to get around by making sure there is a subexpression
in the pattern, however it is an inconsistancy.
RewriteRule /wibble/* http://someserver.somewhereelse.com$0 [R,L]

This will redirect accessing /wibble/wobble to http://someserver.somewhereelse.com$0

If you change the pattern to be:
(/)wibble/*      and it doesn't matter really where you put the subexpression brackets, then
it will work
Then it works.
If you'd rather not change the way the code works, it would be helpful to
document the inconsistancy somewhere. A simple way to fix it would be to remove
the 3 line check on nsub. An alternative way I guess would be to note if there's 
a $0 in the substitution, in the case where nsub is zero.
[In order for any reply to be added to the PR database, ]
[you need to include <apbugs@Apache.Org> in the Cc line ]
[and leave the subject line UNCHANGED.  This is not done]
[automatically because of the potential for mail loops. ]
[If you do not include this Cc, your reply may be ig-   ]
[nored unless you are responding to an explicit request ]
[from a developer.                                      ]
[Reply only with text; DO NOT SEND ATTACHMENTS!         ]

View raw message