[vlc-commits] vlc_UrlParse(): fix handling of port numbers

Rémi Denis-Courmont git at videolan.org
Tue Aug 21 15:07:31 CEST 2012


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Tue Aug 21 16:04:51 2012 +0300| [121973c11e16a9b359e93f109861c83d4a897e2c] | committer: Rémi Denis-Courmont

vlc_UrlParse(): fix handling of port numbers

Pointed-out-by: Aurélien Nephtali <aurelien.nephtali at gmail.com>

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=121973c11e16a9b359e93f109861c83d4a897e2c
---

 src/text/url.c |   20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)

diff --git a/src/text/url.c b/src/text/url.c
index 1ccec85..42473ff 100644
--- a/src/text/url.c
+++ b/src/text/url.c
@@ -454,24 +454,28 @@ void vlc_UrlParse (vlc_url_t *restrict url, const char *str, unsigned char opt)
     }
 
     /* Host name */
-    if (*cur == '[' && (next = strstr (cur, "]:")) != NULL)
-    {
-        /* IPv6 numeral within brackets */
+    if (*cur == '[' && (next = strrchr (cur, ']')) != NULL)
+    {   /* Try IPv6 numeral within brackets */
         *(next++) = '\0';
         url->psz_host = strdup (cur + 1);
+
+        if (*next == ':')
+            next++;
+        else
+            next = NULL;
     }
     else
     {
-        url->psz_host = vlc_idna_to_ascii (cur);
         next = strchr (cur, ':');
+        if (next != NULL)
+            *(next++) = '\0';
+
+        url->psz_host = vlc_idna_to_ascii (cur);
     }
 
     /* Port number */
     if (next != NULL)
-    {
-        assert (*next == ':');
-        url->i_port = atoi (next + 1);
-    }
+        url->i_port = atoi (next);
 
     if (url->psz_path != NULL)
         *url->psz_path = '/'; /* restore leading slash */



More information about the vlc-commits mailing list