Commit 81f738af authored by Alexander Alashkin's avatar Alexander Alashkin Committed by Cesanta Bot

Fix mg_http_common_url_parse

PUBLISHED_FROM=51c44c445309aa0850b227949a0a0a6be433d08c
parent f6165d23
...@@ -7295,6 +7295,7 @@ MG_INTERNAL int mg_http_common_url_parse(const char *url, const char *schema, ...@@ -7295,6 +7295,7 @@ MG_INTERNAL int mg_http_common_url_parse(const char *url, const char *schema,
int addr_len = 0; int addr_len = 0;
int auth_sep_pos = -1; int auth_sep_pos = -1;
int user_sep_pos = -1; int user_sep_pos = -1;
int port_pos = -1;
(void) user; (void) user;
(void) pass; (void) pass;
...@@ -7319,19 +7320,19 @@ MG_INTERNAL int mg_http_common_url_parse(const char *url, const char *schema, ...@@ -7319,19 +7320,19 @@ MG_INTERNAL int mg_http_common_url_parse(const char *url, const char *schema,
} }
if (*url == '@') { if (*url == '@') {
auth_sep_pos = addr_len; auth_sep_pos = addr_len;
user_sep_pos = *port_i; user_sep_pos = port_pos;
*port_i = -1; port_pos = -1;
} }
if (*url == ':') *port_i = addr_len; if (*url == ':') port_pos = addr_len;
(*addr)[addr_len++] = *url; (*addr)[addr_len++] = *url;
(*addr)[addr_len] = '\0'; (*addr)[addr_len] = '\0';
url++; url++;
} }
if (addr_len == 0) goto cleanup; if (addr_len == 0) goto cleanup;
if (*port_i < 0) { if (port_pos < 0) {
*port_i = addr_len; *port_i = *use_ssl ? 443 : 80;
strcpy(*addr + *port_i, *use_ssl ? ":443" : ":80"); addr_len += sprintf(*addr + addr_len, ":%d", *port_i);
} else { } else {
*port_i = -1; *port_i = -1;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment