]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Bug 3023: url_rewrite_program silently fails to rewrite on broken URLs
authorAmos Jeffries <amosjeffries@squid-cache.org>
Thu, 30 Sep 2010 04:45:16 +0000 (22:45 -0600)
committerAmos Jeffries <amosjeffries@squid-cache.org>
Thu, 30 Sep 2010 04:45:16 +0000 (22:45 -0600)
Produce loud cache.log entries displayig the URL instead of silently bypassing.

src/client_side_request.cc

index aae5a4d78c5acf8d16ab3312703905abe399b741..88831270f00768a01ea958ff8f5907f8221e4ab6 100644 (file)
@@ -1009,11 +1009,18 @@ ClientRequestContext::clientRedirectDone(char *result)
             if ((t = strchr(result, ':')) != NULL) {
                 http->redirect.status = status;
                 http->redirect.location = xstrdup(t + 1);
+                // TODO: validate the URL produced here is RFC 2616 compliant absolute URI
             } else {
-                debugs(85, 1, "clientRedirectDone: bad input: " << result);
+                if (old_request->http_ver < HttpVersion(1,1))
+                    debugs(85, DBG_CRITICAL, "ERROR: URL-rewrite produces invalid 302 redirect Location: " << result);
+                else
+                    debugs(85, DBG_CRITICAL, "ERROR: URL-rewrite produces invalid 303 redirect Location: " << result);
             }
-        } else if (strcmp(result, http->uri))
-            new_request = HttpRequest::CreateFromUrlAndMethod(result, old_request->method);
+        } else if (strcmp(result, http->uri)) {
+            if (!(new_request = HttpRequest::CreateFromUrlAndMethod(result, old_request->method)))
+                debugs(85, DBG_CRITICAL, "ERROR: URL-rewrite produces invalid request: " <<
+                       old_request->method << " " << result << " HTTP/1.1");
+        }
     }
 
     if (new_request) {