mirror of
https://github.com/warmcat/libwebsockets.git
synced 2025-03-30 00:00:16 +01:00
url-parser: handle ipv6 [] addresses
This commit is contained in:
parent
7832b236a4
commit
a5f2d8b688
1 changed files with 13 additions and 2 deletions
|
@ -1513,8 +1513,19 @@ lws_parse_uri(char *p, const char **prot, const char **ads, int *port,
|
||||||
else if (!strcmp(*prot, "https") || !strcmp(*prot, "wss"))
|
else if (!strcmp(*prot, "https") || !strcmp(*prot, "wss"))
|
||||||
*port = 443;
|
*port = 443;
|
||||||
|
|
||||||
while (*p && *p != ':' && *p != '/')
|
if (*p == '[')
|
||||||
p++;
|
{
|
||||||
|
++(*ads);
|
||||||
|
while (*p && *p != ']')
|
||||||
|
p++;
|
||||||
|
if (*p)
|
||||||
|
*p++ = '\0';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
while (*p && *p != ':' && *p != '/')
|
||||||
|
p++;
|
||||||
|
}
|
||||||
if (*p == ':') {
|
if (*p == ':') {
|
||||||
*p++ = '\0';
|
*p++ = '\0';
|
||||||
*port = atoi(p);
|
*port = atoi(p);
|
||||||
|
|
Loading…
Add table
Reference in a new issue