Commit 121973c1 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

vlc_UrlParse(): fix handling of port numbers

Pointed-out-by: default avatarAurélien Nephtali <aurelien.nephtali@gmail.com>
parent 82074bd3
...@@ -454,24 +454,28 @@ void vlc_UrlParse (vlc_url_t *restrict url, const char *str, unsigned char opt) ...@@ -454,24 +454,28 @@ void vlc_UrlParse (vlc_url_t *restrict url, const char *str, unsigned char opt)
} }
/* Host name */ /* Host name */
if (*cur == '[' && (next = strstr (cur, "]:")) != NULL) if (*cur == '[' && (next = strrchr (cur, ']')) != NULL)
{ { /* Try IPv6 numeral within brackets */
/* IPv6 numeral within brackets */
*(next++) = '\0'; *(next++) = '\0';
url->psz_host = strdup (cur + 1); url->psz_host = strdup (cur + 1);
if (*next == ':')
next++;
else
next = NULL;
} }
else else
{ {
url->psz_host = vlc_idna_to_ascii (cur);
next = strchr (cur, ':'); next = strchr (cur, ':');
if (next != NULL)
*(next++) = '\0';
url->psz_host = vlc_idna_to_ascii (cur);
} }
/* Port number */ /* Port number */
if (next != NULL) if (next != NULL)
{ url->i_port = atoi (next);
assert (*next == ':');
url->i_port = atoi (next + 1);
}
if (url->psz_path != NULL) if (url->psz_path != NULL)
*url->psz_path = '/'; /* restore leading slash */ *url->psz_path = '/'; /* restore leading slash */
......
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