From 195202affa6f167d850f39c66aa50ae346df4ce4 Mon Sep 17 00:00:00 2001 From: "Paul J. Reder" Date: Wed, 4 Feb 2004 15:57:36 +0000 Subject: [PATCH] *) mod_rewrite: Catch an edge case, where strange subsequent RewriteRules could lead to a 400 (Bad Request) response. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Submitted by: Andr�� Malo Reviewed by: jerenkrantz, rederpj git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/APACHE_2_0_BRANCH@102500 13f79535-47bb-0310-9956-ffa450edef68 --- CHANGES | 3 +++ STATUS | 7 +------ modules/mappers/mod_rewrite.c | 8 ++------ 3 files changed, 6 insertions(+), 12 deletions(-) diff --git a/CHANGES b/CHANGES index f63b7bc169f..f030a51cc2f 100644 --- a/CHANGES +++ b/CHANGES @@ -1,5 +1,8 @@ Changes with Apache 2.0.49 + *) mod_rewrite: Catch an edge case, where strange subsequent RewriteRules + could lead to a 400 (Bad Request) response. [André Malo] + *) Keep focus of ITERATE and ITERATE2 on the current module when the module chooses to return DECLINE_CMD for the directive. PR 22299. [Geoffrey Young ] diff --git a/STATUS b/STATUS index c8a646d5310..78871f47f80 100644 --- a/STATUS +++ b/STATUS @@ -1,5 +1,5 @@ APACHE 2.0 STATUS: -*-text-*- -Last modified at [$Date: 2004/02/04 15:09:31 $] +Last modified at [$Date: 2004/02/04 15:57:35 $] Release: @@ -210,11 +210,6 @@ PATCHES TO BACKPORT FROM 2.1 PREREQ: Blow away of SSL_EXPERIMENTAL_ENGINE (see above) +1: jwoolley, trawick, jim, jerenkrantz - * Catch an edge case, where strange subsequent RewriteRules could lead to - a 400 (Bad Request) response. (2.0 + 1.3) - modules/mappers/mod_rewrite.c: r1.228 - +1: nd, jerenkrantz - * mod_include's expression tokenizer: don't skip the first character of a string, it may be a backslash. (2.0 + 1.3) (patch for 2.0: http://cvs.apache.org/~nd/ssi-escape.patch) diff --git a/modules/mappers/mod_rewrite.c b/modules/mappers/mod_rewrite.c index 0b3ad660f90..d4bee70ae20 100644 --- a/modules/mappers/mod_rewrite.c +++ b/modules/mappers/mod_rewrite.c @@ -1943,7 +1943,6 @@ static int apply_rewrite_rule(request_rec *r, rewriterule_entry *p, regmatch_t regmatch[AP_MAX_REG_MATCH]; backrefinfo *briRR = NULL; backrefinfo *briRC = NULL; - int prefixstrip; int failed; apr_array_header_t *rewriteconds; rewritecond_entry *conds; @@ -1974,14 +1973,12 @@ static int apply_rewrite_rule(request_rec *r, rewriterule_entry *p, * the local part. Additionally indicate this special * threatment in the logfile. */ - prefixstrip = 0; - if (perdir != NULL) { + if (perdir) { if ( strlen(uri) >= strlen(perdir) && strncmp(uri, perdir, strlen(perdir)) == 0) { rewritelog(r, 3, "[per-dir %s] strip per-dir prefix: %s -> %s", perdir, uri, uri+strlen(perdir)); uri = uri+strlen(perdir); - prefixstrip = 1; } } @@ -2177,8 +2174,7 @@ static int apply_rewrite_rule(request_rec *r, rewriterule_entry *p, * location, i.e. if it's not an absolute URL (!) path nor * a fully qualified URL scheme. */ - if (prefixstrip && *r->filename != '/' - && !is_absolute_uri(r->filename)) { + if (perdir && *r->filename != '/' && !is_absolute_uri(r->filename)) { rewritelog(r, 3, "[per-dir %s] add per-dir prefix: %s -> %s%s", perdir, r->filename, perdir, r->filename); r->filename = apr_pstrcat(r->pool, perdir, r->filename, NULL); -- 2.47.2