]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
Merge r1735088 from trunk:
authorStefan Eissing <icing@apache.org>
Thu, 17 Mar 2016 09:28:51 +0000 (09:28 +0000)
committerStefan Eissing <icing@apache.org>
Thu, 17 Mar 2016 09:28:51 +0000 (09:28 +0000)
[PATCH] mod_rewrite: double escaping of query strings in server context
(like PR50447, for server context)

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1735379 13f79535-47bb-0310-9956-ffa450edef68

CHANGES
STATUS
modules/mappers/mod_rewrite.c

diff --git a/CHANGES b/CHANGES
index a76dcaf545c2b41d0277206941058aa169b1123e..caf8a8df27c7c23fe108429030aa454a7253f206 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -2,6 +2,10 @@
 
 Changes with Apache 2.4.19
 
+  *) mod_rewrite: Don't implicitly URL-escape the original query string
+     when no substitution has changed it (like PR50447 but server context)
+     [Evgeny Kotkov <evgeny.kotkov visualsvn.com>]
+
   *) mod_http2: fixes problem with wrong lifetime of file buckets on main
      connection. [Stefan Eissing]
      
diff --git a/STATUS b/STATUS
index bc3207e13b62725c2d7f985296c9c2534084c051..398f4522ce3217d5634bd0a224eb368924724551 100644 (file)
--- a/STATUS
+++ b/STATUS
@@ -112,12 +112,6 @@ RELEASE SHOWSTOPPERS:
 PATCHES ACCEPTED TO BACKPORT FROM TRUNK:
   [ start all new proposals below, under PATCHES PROPOSED. ]
 
-  *) mod_rewrite: Don't escape an unchanged query string, in server context. 
-                  Was fixed in 2010 for directory context.
-     trunk patch: http://svn.apache.org/r1735088
-     2.4.x patch: trunk works
-     +1 covener, ylavic, icing
-
 
 PATCHES PROPOSED TO BACKPORT FROM TRUNK:
   [ New proposals should be added at the end of the list ]
index 1cf110be6c24a7b33f8be6e3b6ed80865886c3d9..d31b1c24632bf6c753dbea09ba566f5fa6ab4030 100644 (file)
@@ -4493,6 +4493,7 @@ static int hook_uri2file(request_rec *r)
     unsigned int port;
     int rulestatus;
     void *skipdata;
+    const char *oargs;
 
     /*
      *  retrieve the config structures
@@ -4542,6 +4543,12 @@ static int hook_uri2file(request_rec *r)
         return DECLINED;
     }
 
+    /*
+     *  remember the original query string for later check, since we don't
+     *  want to apply URL-escaping when no substitution has changed it.
+     */
+    oargs = r->args;
+
     /*
      *  add the SCRIPT_URL variable to the env. this is a bit complicated
      *  due to the fact that apache uses subrequests and internal redirects
@@ -4676,11 +4683,21 @@ static int hook_uri2file(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, NULL, "%s %s to query string for redirect %s",
+                            noescape ? "copying" : "escaping",
+                            r->args ,
+                            noescape ? "" : escaped_args));
             }
 
             /* determine HTTP redirect response code */