Received: (qmail 16947 invoked by uid 2012); 29 Mar 1999 12:27:40 -0000 Message-Id: <19990329122740.16946.qmail@hyperreal.org> Date: 29 Mar 1999 12:27:40 -0000 From: Matt Hoskins Reply-To: matt@nipltd.com To: apbugs@hyperreal.org Subject: $0 can't be used in the substitution if there are no subexpressions X-Send-Pr-Version: 3.2 >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: closed >Class: sw-bug >Submitter-Id: apache >Arrival-Date: Mon Mar 29 04:30:01 PST 1999 >Last-Modified: Wed Oct 27 02:21:43 PDT 1999 >Originator: matt@nipltd.com >Organization: >Release: 1.3.6 >Environment: SunOS 5.5.1 >Description: In the function expand_backref_inbuffer in mod_rewrite.c the function has: if(bri->nsub<1) { return; } 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. >How-To-Repeat: 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. >Fix: 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. >Audit-Trail: State-Changed-From-To: open-closed State-Changed-By: rse State-Changed-When: Wed Oct 27 02:21:43 PDT 1999 State-Changed-Why: $0 is now officially allowed and documented for Apache 1.3.10. Thanks for your feedback. >Unformatted: [In order for any reply to be added to the PR database, ] [you need to include 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! ]