]> granicus.if.org Git - apache/commitdiff
Don't just willy nilly slurp double slashes... just handle
authorJim Jagielski <jim@apache.org>
Mon, 17 Sep 2012 12:22:33 +0000 (12:22 +0000)
committerJim Jagielski <jim@apache.org>
Mon, 17 Sep 2012 12:22:33 +0000 (12:22 +0000)
the end-case where a '//' is not intended (due to how
PPR is stored)

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

modules/proxy/proxy_util.c

index 5e7bd764ca15913645261f34a21fcc3e02947428..a69483ba4a54aae1ebac373bfdcc3a636921eed9 100644 (file)
@@ -859,7 +859,6 @@ PROXY_DECLARE(const char *) ap_proxy_location_reverse_map(request_rec *r,
         if (ap_proxy_valid_balancer_name((char *)real, 0) &&
             (balancer = ap_proxy_get_balancer(r->pool, sconf, real, 1))) {
             int n, l3 = 0;
-            int fake_endwslash = (ent[i].fake[strlen(ent[i].fake)-1] == '/');
             proxy_worker **worker = (proxy_worker **)balancer->workers->elts;
             const char *urlpart = ap_strchr_c(real + sizeof(BALANCER_PREFIX) - 1, '/');
             if (urlpart) {
@@ -882,21 +881,18 @@ PROXY_DECLARE(const char *) ap_proxy_location_reverse_map(request_rec *r,
                     if (l1 >= l2 + l3
                             && strncasecmp((*worker)->s->name, url, l2) == 0
                             && strncmp(urlpart, url + l2, l3) == 0) {
-                        /* Avoid double-slash when concatting */
-                        if (fake_endwslash && (url[l2 + l3] == '/')) {
-                            l2++;
-                        }
                         u = apr_pstrcat(r->pool, ent[i].fake, &url[l2 + l3],
                                         NULL);
                         return ap_is_url(u) ? u : ap_construct_url(r->pool, u, r);
                     }
                 }
                 else if (l1 >= l2 && strncasecmp((*worker)->s->name, url, l2) == 0) {
-                    /* Avoid double-slash when concatting */
-                    if (fake_endwslash && (url[l2] == '/')) {
-                        l2++;
+                    /* edge case where fake is just "/"... avoid double slash */
+                    if ((ent[i].fake[0] == '/') && (ent[i].fake[1] == 0) && (url[l2] == '/')) {
+                        u = apr_pstrdup(r->pool, &url[l2]);
+                    } else {
+                        u = apr_pstrcat(r->pool, ent[i].fake, &url[l2], NULL);
                     }
-                    u = apr_pstrcat(r->pool, ent[i].fake, &url[l2], NULL);
                     return ap_is_url(u) ? u : ap_construct_url(r->pool, u, r);
                 }
                 worker++;