mirror of
https://github.com/cesanta/mongoose.git
synced 2025-06-20 02:11:56 +08:00
Fix mg_http_common_url_parse
PUBLISHED_FROM=51c44c445309aa0850b227949a0a0a6be433d08c
This commit is contained in:
parent
f6165d23e4
commit
81f738af3f
13
mongoose.c
13
mongoose.c
@ -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,
|
|||||||
}
|
}
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user