]> granicus.if.org Git - curl/commitdiff
parse_remote_port: ignore colons without port number
authorDaniel Stenberg <daniel@haxx.se>
Tue, 21 Sep 2010 17:51:30 +0000 (19:51 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Tue, 21 Sep 2010 17:51:30 +0000 (19:51 +0200)
Obviously, browsers ignore a colon without a following port number. Both
Firefox and Chrome just removes the colon for such URLs. This change
does not remove the colon for URLs sent over a HTTP proxy, so we should
consider doing that change as well.

Reported by: github user 'kreshano'

lib/url.c

index 1334186815f66c150c7553d6a0a087b630ff034c..7fe713d3e05660227ed485777f8e32d2147314a2 100644 (file)
--- a/lib/url.c
+++ b/lib/url.c
@@ -4319,6 +4319,11 @@ static CURLcode parse_remote_port(struct SessionHandle *data,
       *portptr = '\0'; /* cut off the name there */
       conn->remote_port = curlx_ultous(port);
     }
+    else if(!port)
+      /* Browser behavior adaptation. If there's a colon with no digits after,
+         just cut off the name there which makes us ignore the colon and just
+         use the default port. Firefox and Chrome both do that. */
+      *portptr = '\0';
   }
   return CURLE_OK;
 }