]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Bug 3074: Improper URL handling with empty path (RFC 3986)
authorFyodor <fygrave@gmail.com>
Tue, 5 Jun 2012 09:06:55 +0000 (03:06 -0600)
committerAmos Jeffries <squid3@treenet.co.nz>
Tue, 5 Jun 2012 09:06:55 +0000 (03:06 -0600)
src/url.cc

index 82e5d632fc85a5619920fcf019913e78eea5e4c9..6222fe729ac40b49bc883437cca9abcf0e9702f5 100644 (file)
@@ -267,8 +267,9 @@ urlParse(const HttpRequestMethod& method, char *url, HttpRequest *request)
         src += 3;
 
         /* Then everything until first /; thats host (and port; which we'll look for here later) */
-        /* bug 1881: If we don't get a "/" then we imply it was there */
-        for (dst = host; i < l && *src != '/' && *src != '\0'; i++, src++, dst++) {
+        // bug 1881: If we don't get a "/" then we imply it was there
+        // bug 3074: We could just be given a "?" or "#". These also imply "/"
+        for (dst = host; i < l && *src != '/' && *src != '?' && *src != '#' && *src != '\0'; i++, src++, dst++) {
             *dst = *src;
         }
 
@@ -281,8 +282,15 @@ urlParse(const HttpRequestMethod& method, char *url, HttpRequest *request)
             return NULL;
         *dst = '\0';
 
+        // bug 3074: received 'path' starting with '?', '#', or '\0' implies '/'
+        if (*src == '?' || *src == '#' || *src == '\0') {
+            urlpath[0] = '/';
+            dst = &urlpath[1];
+        } else {
+            dst = urlpath;
+        }
         /* Then everything from / (inclusive) until \r\n or \0 - thats urlpath */
-        for (dst = urlpath; i < l && *src != '\r' && *src != '\n' && *src != '\0'; i++, src++, dst++) {
+        for (; i < l && *src != '\r' && *src != '\n' && *src != '\0'; i++, src++, dst++) {
             *dst = *src;
         }