url-parser: handle ipv6 [] addresses

This commit is contained in:
Silas Parker 2017-02-21 07:27:07 +08:00 committed by Andy Green
parent 7832b236a4
commit a5f2d8b688

View file

@ -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"))
*port = 443;
while (*p && *p != ':' && *p != '/')
p++;
if (*p == '[')
{
++(*ads);
while (*p && *p != ']')
p++;
if (*p)
*p++ = '\0';
}
else
{
while (*p && *p != ':' && *p != '/')
p++;
}
if (*p == ':') {
*p++ = '\0';
*port = atoi(p);