]> git.sesse.net Git - vlc/blobdiff - include/vlc_url.h
Improved vlc_UrlParse (close #1025)
[vlc] / 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 */