Return-Path: Delivered-To: apmail-apache-bugdb-archive@apache.org Received: (qmail 54868 invoked by uid 500); 18 Jan 2001 04:40:01 -0000 Mailing-List: contact apache-bugdb-help@apache.org; run by ezmlm Precedence: bulk Reply-To: apache-bugdb@apache.org list-help: list-unsubscribe: list-post: Delivered-To: mailing list apache-bugdb@apache.org Received: (qmail 54849 invoked by uid 501); 18 Jan 2001 04:40:01 -0000 Resent-Date: 18 Jan 2001 04:40:01 -0000 Resent-Message-ID: <20010118044001.54847.qmail@apache.org> Resent-From: submit@bugz.apache.org (GNATS Filer) Resent-To: apache-bugdb@apache.org Resent-Cc: apache-bugdb@apache.org Resent-Reply-To: submit@bugz.apache.org, dean2@biol.sc.edu Received: (qmail 39259 invoked by uid 501); 18 Jan 2001 04:32:13 -0000 Message-Id: <20010118043213.39222.qmail@apache.org> Date: 18 Jan 2001 04:32:13 -0000 From: Dean Pentcheff Reply-To: dean2@biol.sc.edu To: submit@bugz.apache.org X-Send-Pr-Version: 3.110 Subject: mod_rewrite/7087: Expansion of %{LA-U:REMOTE_USER} fails in RewriteCond >Number: 7087 >Category: mod_rewrite >Synopsis: Expansion of %{LA-U:REMOTE_USER} fails in RewriteCond >Confidential: no >Severity: serious >Priority: medium >Responsible: apache >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: apache >Arrival-Date: Wed Jan 17 20:40:01 PST 2001 >Closed-Date: >Last-Modified: >Originator: dean2@biol.sc.edu >Release: 1.3.14 >Organization: apache >Environment: Redhat Linux 6.1, kernel 2.2.14-6.0.1smp, gcc 2.7.2.3 >Description: Preliminaries: this rewrite pattern worked on 1.3.11 but fails on 1.3.14. It is NOT fixed by apache_1.3.14-fix.diff. A temporary workaround for me has been to simply use the mod_rewrite.{c,h} from 1.3.11 inside an otherwise normal 1.3.14 tree. Briefly, the %{LA-U:REMOTE_USER} variable fails proper expansion in (at least) the RewriteCond pattern context. Based on logfiles, it appears that it may be due to a parsing error that whacks off the final "}" which leads to interpretation as a string rather than being variable-expanded. I suspect that this has to do with the new "do_expand()" parsing rather than the old method (note that's a suspicion, not a certainty). If you look at the working trace below (the upper set), you can see that initially the REMOTE_USER variable is empty prior to the lookahead, therefore failing to trigger a rewrite because of the RewriteCond. Next, the the lookahead triggers, finds the variable's value ("mailtest"), and the rewrite succeeds in inserting the value into the URL. In the non-working trace (the lower set), the initial check on the RewriteCond succeeds when it shouldn't. The RewriteCond pattern appears to have its trailing "}" lost, leading to treatment of the variable expression as a string to match. Since the RewriteCond succeeds, the rewrite occurs, filling in an empty string (generating "//pab.na2"). That suggests that variable expansion at that point is working (in contrast to the RewriteCond stage). Weirdly, then the lookahead goes ahead with what looks like a good variable name, but fails to find the value. The upshot is that the variable's proper value never gets inserted into the URL. Following are the data (trace lines have had IPs and dates trimmed). The working trace is generated from a 1.3.14 tree with the 1.3.11 mod_rewrite substituted into it; the failing trace is straight 1.3.14. Rewrite pattern (tokens are tab-separated) ========================================== RewriteCond %{LA-U:REMOTE_USER} !^$ RewriteRule ^.*/(.*) /%{LA-U:REMOTE_USER}/$1 [L] Trace from a RewriteLogLevel 9 with the 1.3.11 mod_rewrite (WORKING) ==================================================================== client - - [date] [server/sid#8332fb8][rid#8398708/initial] (2) init rewrite engine with requested uri /pab.na2 client - - [date] [server/sid#8332fb8][rid#8398708/initial] (3) applying pattern '^.*/(.*)' to uri '/pab.na2' client - - [date] [server/sid#8332fb8][rid#83835e0/subreq] (2) init rewrite engine with requested uri /pab.na2 client - - [date] [server/sid#8332fb8][rid#83835e0/subreq] (3) applying pattern '^.*/(.*)' to uri '/pab.na2' client - - [date] [server/sid#8332fb8][rid#83835e0/subreq] (4) RewriteCond: input='' pattern='!^$' => not-matched client - - [date] [server/sid#8332fb8][rid#83835e0/subreq] (1) pass through /pab.na2 client - mailtest [date] [server/sid#8332fb8][rid#8398708/initial] (5) lookahead: path=/pab.na2 var=REMOTE_USER -> val=mailtest client - mailtest [date] [server/sid#8332fb8][rid#8398708/initial] (4) RewriteCond: input='mailtest' pattern='!^$' => matched client - mailtest [date] [server/sid#8332fb8][rid#83835e0/subreq] (2) init rewrite engine with requested uri /pab.na2 client - mailtest [date] [server/sid#8332fb8][rid#83835e0/subreq] (3) applying pattern '^.*/(.*)' to uri '/pab.na2' client - mailtest [date] [server/sid#8332fb8][rid#83835e0/subreq] (4) RewriteCond: input='' pattern='!^$' => not-matched client - mailtest [date] [server/sid#8332fb8][rid#83835e0/subreq] (1) pass through /pab.na2 client - mailtest [date] [server/sid#8332fb8][rid#8398708/initial] (5) lookahead: path=/pab.na2 var=REMOTE_USER -> val=mailtest client - mailtest [date] [server/sid#8332fb8][rid#8398708/initial] (2) rewrite /pab.na2 -> /mailtest/pab.na2 client - mailtest [date] [server/sid#8332fb8][rid#8398708/initial] (2) local path result: /mailtest/pab.na2 client - mailtest [date] [server/sid#8332fb8][rid#8398708/initial] (2) prefixed with document_root to /usr/local/apache/mail/mailtest/pab.na2 client - mailtest [date] [server/sid#8332fb8][rid#8398708/initial] (1) go-ahead with /usr/local/apache/mail/mailtest/pab.na2 [OK] Trace from a RewriteLogLevel 9 with the 1.3.14 mod_rewrite (FAILING) ==================================================================== client - - [date] [server/sid#8332558][rid#836c340/initial] (2) init rewrite engine with requested uri /pab.na2 client - - [date] [server/sid#8332558][rid#836c340/initial] (3) applying pattern '^.*/(.*)' to uri '/pab.na2' client - - [date] [server/sid#8332558][rid#8394790/subreq] (2) init rewrite engine with requested uri /pab.na2 client - - [date] [server/sid#8332558][rid#8394790/subreq] (3) applying pattern '^.*/(.*)' to uri '/pab.na2' client - - [date] [server/sid#8332558][rid#8394790/subreq] (4) RewriteCond: input='%{LA-U:REMOTE_USER' pattern='!^$' => matched client - - [date] [server/sid#8332558][rid#8394790/subreq] (2) rewrite /pab.na2 -> //pab.na2 client - - [date] [server/sid#8332558][rid#8394790/subreq] (2) local path result: //pab.na2 client - - [date] [server/sid#8332558][rid#8394790/subreq] (1) go-ahead with //pab.na2 [OK] client - - [date] [server/sid#8332558][rid#836c340/initial] (5) lookahead: path=/pab.na2 var=REMOTE_USER -> val= client - - [date] [server/sid#8332558][rid#836c340/initial] (4) RewriteCond: input='' pattern='!^$' => not-matched client - - [date] [server/sid#8332558][rid#836c340/initial] (1) pass through /pab.na2 === end of bug report === >How-To-Repeat: >Fix: Possibly an error introduced in the rewriting of variable parsing into the "do_expand()" routine. >Release-Note: >Audit-Trail: >Unformatted: [In order for any reply to be added to the PR database, you need] [to include in the Cc line and make sure the] [subject line starts with the report component and number, with ] [or without any 'Re:' prefixes (such as "general/1098:" or ] ["Re: general/1098:"). If the subject doesn't match this ] [pattern, your message will be misfiled and ignored. The ] ["apbugs" address is not added to the Cc line of messages from ] [the database 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! ]