From: Eric Covener Date: Sat, 11 Dec 2010 16:14:06 +0000 (+0000) Subject: PR 50447: mod_rewrite escapes the original [escaped] query string even when X-Git-Tag: 2.3.10~23 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=fce013d2343fce6e1bbd53e094fe883caf1225bd;p=apache PR 50447: mod_rewrite escapes the original [escaped] query string even when you haven't modified it. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1044673 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/CHANGES b/CHANGES index 8fbbcba7b4..4bccbf770f 100644 --- a/CHANGES +++ b/CHANGES @@ -2,6 +2,9 @@ Changes with Apache 2.3.10 + *) mod_rewrite: Don't implicitly URL-escape the original query string + when no substitution has changed it. PR 50447. [Eric Covener] + *) core: Honor 'AcceptPathInfo OFF' during internal redirects, such as per-directory mod_rewrite substitutions. PR 50349. [Eric Covener] diff --git a/modules/mappers/mod_rewrite.c b/modules/mappers/mod_rewrite.c index 431e5fa8d5..44ff0b46cc 100644 --- a/modules/mappers/mod_rewrite.c +++ b/modules/mappers/mod_rewrite.c @@ -4636,7 +4636,7 @@ static int hook_fixup(request_rec *r) apr_size_t l; int rulestatus; int n; - char *ofilename; + char *ofilename, *oargs; int is_proxyreq; void *skipdata; @@ -4710,6 +4710,7 @@ static int hook_fixup(request_rec *r) * request */ ofilename = r->filename; + oargs = r->args; if (r->filename == NULL) { r->filename = apr_pstrdup(r->pool, r->uri); @@ -4814,11 +4815,20 @@ static int hook_fixup(request_rec *r) /* append the QUERY_STRING part */ if (r->args) { + char *escaped_args = NULL; + int noescape = (rulestatus == ACTION_NOESCAPE || + (oargs && !strcmp(r->args, oargs))); + r->filename = apr_pstrcat(r->pool, r->filename, "?", - (rulestatus == ACTION_NOESCAPE) + noescape ? r->args - : ap_escape_uri(r->pool, r->args), + : (escaped_args = ap_escape_uri(r->pool, r->args)), NULL); + + rewritelog((r, 1, dconf->directory, "%s %s to query string for redirect %s", + noescape ? "copying" : "escaping", + r->args , + noescape ? "" : escaped_args)); } /* determine HTTP redirect response code */