Return-Path: Delivered-To: apmail-httpd-cvs-archive@www.apache.org Received: (qmail 51484 invoked from network); 31 Dec 2008 00:08:31 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 31 Dec 2008 00:08:31 -0000 Received: (qmail 10090 invoked by uid 500); 31 Dec 2008 00:08:31 -0000 Delivered-To: apmail-httpd-cvs-archive@httpd.apache.org Received: (qmail 10036 invoked by uid 500); 31 Dec 2008 00:08:31 -0000 Mailing-List: contact cvs-help@httpd.apache.org; run by ezmlm Precedence: bulk Reply-To: dev@httpd.apache.org list-help: list-unsubscribe: List-Post: List-Id: Delivered-To: mailing list cvs@httpd.apache.org Received: (qmail 10027 invoked by uid 99); 31 Dec 2008 00:08:31 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 30 Dec 2008 16:08:31 -0800 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 31 Dec 2008 00:08:21 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 4A75E2388995; Tue, 30 Dec 2008 16:08:01 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r730274 - in /httpd/httpd/trunk: CHANGES modules/mappers/mod_rewrite.c Date: Wed, 31 Dec 2008 00:08:01 -0000 To: cvs@httpd.apache.org From: niq@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20081231000801.4A75E2388995@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: niq Date: Tue Dec 30 16:08:00 2008 New Revision: 730274 URL: http://svn.apache.org/viewvc?rev=730274&view=rev Log: Fix mod_rewrite "B" flag breakage by reverting r589343 PR#45529 Modified: httpd/httpd/trunk/CHANGES httpd/httpd/trunk/modules/mappers/mod_rewrite.c Modified: httpd/httpd/trunk/CHANGES URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/CHANGES?rev=730274&r1=730273&r2=730274&view=diff ============================================================================== --- httpd/httpd/trunk/CHANGES [utf-8] (original) +++ httpd/httpd/trunk/CHANGES [utf-8] Tue Dec 30 16:08:00 2008 @@ -2,6 +2,9 @@ Changes with Apache 2.3.1 [ When backported to 2.2.x, remove entry from this file ] + *) mod_rewrite: fix "B" flag breakage by reverting r5589343 + PR 45529 [Bob Ionescu ] + *) CGI: return 504 (Gateway timeout) rather than 500 when a script times out before returning status line/headers. PR 42190 [Nick Kew] Modified: httpd/httpd/trunk/modules/mappers/mod_rewrite.c URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/mappers/mod_rewrite.c?rev=730274&r1=730273&r2=730274&view=diff ============================================================================== --- httpd/httpd/trunk/modules/mappers/mod_rewrite.c (original) +++ httpd/httpd/trunk/modules/mappers/mod_rewrite.c Tue Dec 30 16:08:00 2008 @@ -389,6 +389,7 @@ /* Optional functions imported from mod_ssl when loaded: */ static APR_OPTIONAL_FN_TYPE(ssl_var_lookup) *rewrite_ssl_lookup = NULL; static APR_OPTIONAL_FN_TYPE(ssl_is_https) *rewrite_is_https = NULL; +static char *escape_uri(apr_pool_t *p, const char *path); /* * +-------------------------------------------------------+ @@ -658,6 +659,46 @@ return 0; } +static const char c2x_table[] = "0123456789abcdef"; + +static APR_INLINE unsigned char *c2x(unsigned what, unsigned char prefix, + unsigned char *where) +{ +#if APR_CHARSET_EBCDIC + what = apr_xlate_conv_byte(ap_hdrs_to_ascii, (unsigned char)what); +#endif /*APR_CHARSET_EBCDIC*/ + *where++ = prefix; + *where++ = c2x_table[what >> 4]; + *where++ = c2x_table[what & 0xf]; + return where; +} + +/* + * Escapes a uri in a similar way as php's urlencode does. + * Based on ap_os_escape_path in server/util.c + */ +static char *escape_uri(apr_pool_t *p, const char *path) { + char *copy = apr_palloc(p, 3 * strlen(path) + 3); + const unsigned char *s = (const unsigned char *)path; + unsigned char *d = (unsigned char *)copy; + unsigned c; + + while ((c = *s)) { + if (apr_isalnum(c) || c == '_') { + *d++ = c; + } + else if (c == ' ') { + *d++ = '+'; + } + else { + d = c2x(c, '%', d); + } + ++s; + } + *d = '\0'; + return copy; +} + /* * escape absolute uri, which may or may not be path oriented. * So let's handle them differently. @@ -2363,15 +2404,16 @@ if (entry && (entry->flags & RULEFLAG_ESCAPEBACKREF)) { /* escape the backreference */ char *tmp2, *tmp; - tmp = apr_pstrndup(pool, bri->source + bri->regmatch[n].rm_so, span); - tmp2 = ap_escape_path_segment(pool, tmp); + tmp = apr_palloc(pool, span + 1); + strncpy(tmp, bri->source + bri->regmatch[n].rm_so, span); + tmp[span] = '\0'; + tmp2 = escape_uri(pool, tmp); rewritelog((ctx->r, 5, ctx->perdir, "escaping backreference '%s' to '%s'", tmp, tmp2)); current->len = span = strlen(tmp2); current->string = tmp2; - } - else { + } else { current->len = span; current->string = bri->source + bri->regmatch[n].rm_so; }