PR 50447: mod_rewrite escapes the original [escaped] query string even when
authorEric Covener <covener@apache.org>
Sat, 11 Dec 2010 16:14:06 +0000 (16:14 +0000)
committerEric Covener <covener@apache.org>
Sat, 11 Dec 2010 16:14:06 +0000 (16:14 +0000)
you haven't modified it.

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1044673 13f79535-47bb-0310-9956-ffa450edef68

CHANGES
modules/mappers/mod_rewrite.c

diff --git a/CHANGES b/CHANGES
index 8fbbcba7b4ca084a66c895263a19c7947b4c4158..4bccbf770f164c2cddde1b617d6219af1e1b82b2 100644 (file)
--- 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]
index 431e5fa8d5b339f31e068ef5e42798ba27ef71fe..44ff0b46cc54199796e60b9cfe2dab55346c0ba2 100644 (file)
@@ -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 */