Loading lib/urlapi.c +9 −9 Changes for lib/urlapi.c: 9 added lines, 9 removed lines. Original line number Diff line number Diff line Loading @@ -534,6 +534,14 @@ UNITTEST CURLUcode Curl_parse_port(struct Curl_URL *u, char *hostname) long port; char portbuf[7]; /* 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, Chrome and Safari all do that. */ if(!portptr[1]) { *portptr = '\0'; return CURLUE_OK; } if(!ISDIGIT(portptr[1])) return CURLUE_BAD_PORT_NUMBER; Loading @@ -547,23 +555,15 @@ UNITTEST CURLUcode Curl_parse_port(struct Curl_URL *u, char *hostname) if(rest[0]) return CURLUE_BAD_PORT_NUMBER; if(rest != &portptr[1]) { *portptr++ = '\0'; /* cut off the name there */ *rest = 0; /* generate a new to get rid of leading zeroes etc */ /* generate a new port number string to get rid of leading zeroes etc */ msnprintf(portbuf, sizeof(portbuf), "%ld", port); u->portnum = port; u->port = strdup(portbuf); if(!u->port) return CURLUE_OUT_OF_MEMORY; } else { /* 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 CURLUE_OK; } Loading tests/unit/unit1653.c +8 Changes for tests/unit/unit1653.c: 8 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -110,6 +110,14 @@ UNITTEST_START free(ipv6port); curl_url_cleanup(u); /* Valid IPv6 with no port after the colon, should use default */ u = curl_url(); ipv6port = strdup("[fe80::250:56ff:fea7:da15]:"); ret = Curl_parse_port(u, ipv6port); fail_unless(ret == CURLUE_OK, "Curl_parse_port returned error"); free(ipv6port); curl_url_cleanup(u); /* Incorrect zone index syntax */ u = curl_url(); ipv6port = strdup("[fe80::250:56ff:fea7:da15%!25eth3]:80"); Loading Loading
lib/urlapi.c +9 −9 Changes for lib/urlapi.c: 9 added lines, 9 removed lines. Original line number Diff line number Diff line Loading @@ -534,6 +534,14 @@ UNITTEST CURLUcode Curl_parse_port(struct Curl_URL *u, char *hostname) long port; char portbuf[7]; /* 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, Chrome and Safari all do that. */ if(!portptr[1]) { *portptr = '\0'; return CURLUE_OK; } if(!ISDIGIT(portptr[1])) return CURLUE_BAD_PORT_NUMBER; Loading @@ -547,23 +555,15 @@ UNITTEST CURLUcode Curl_parse_port(struct Curl_URL *u, char *hostname) if(rest[0]) return CURLUE_BAD_PORT_NUMBER; if(rest != &portptr[1]) { *portptr++ = '\0'; /* cut off the name there */ *rest = 0; /* generate a new to get rid of leading zeroes etc */ /* generate a new port number string to get rid of leading zeroes etc */ msnprintf(portbuf, sizeof(portbuf), "%ld", port); u->portnum = port; u->port = strdup(portbuf); if(!u->port) return CURLUE_OUT_OF_MEMORY; } else { /* 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 CURLUE_OK; } Loading
tests/unit/unit1653.c +8 Changes for tests/unit/unit1653.c: 8 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -110,6 +110,14 @@ UNITTEST_START free(ipv6port); curl_url_cleanup(u); /* Valid IPv6 with no port after the colon, should use default */ u = curl_url(); ipv6port = strdup("[fe80::250:56ff:fea7:da15]:"); ret = Curl_parse_port(u, ipv6port); fail_unless(ret == CURLUE_OK, "Curl_parse_port returned error"); free(ipv6port); curl_url_cleanup(u); /* Incorrect zone index syntax */ u = curl_url(); ipv6port = strdup("[fe80::250:56ff:fea7:da15%!25eth3]:80"); Loading