]> git.sesse.net Git - vlc/commitdiff
Improved vlc_UrlParse (close #1025)
authorLaurent Aimar <fenrir@videolan.org>
Wed, 21 Feb 2007 21:31:36 +0000 (21:31 +0000)
committerLaurent Aimar <fenrir@videolan.org>
Wed, 21 Feb 2007 21:31:36 +0000 (21:31 +0000)
 We use vlc_UrlParse for "URL" without protocol... so it was using a part of
the URL as a protocol if it found ":/". Ensure to extract only valid protocol
at least.

include/vlc_url.h

index 99d280fd20907e71c2973327289892a098c7f2a5..4001596763856aaf11b15d01a5e134f5dd425429 100644 (file)
@@ -73,7 +73,23 @@ static inline void vlc_UrlParse( vlc_url_t *url, const char *psz_url,
     }
     url->psz_buffer = psz_parse = psz_dup = strdup( psz_url );
 
+    /* Search a valid protocol */
     p  = strstr( psz_parse, ":/" );
+    if( p != NULL )
+    {
+        char *p2;
+        for( p2 = psz_parse; p2 < p; p2++ )
+        {
+#define I(i,a,b) ( (a) <= (i) && (i) <= (b) )
+            if( !I(*p2, 'a', 'z' ) && !I(*p2, 'A', 'Z') && !I(*p2, '0', '9') && *p2 != '+' && *p2 != '-' && *p2 != '.' )
+            {
+                p = NULL;
+                break;
+            }
+#undef I
+        }
+    }
+
     if( p != NULL )
     {
         /* we have a protocol */