]> git.sesse.net Git - vlc/blobdiff - activex/utils.cpp
Missing #include on Win32
[vlc] / activex / utils.cpp
index 8750aa1ce2e6749e3e3b9492829a4d2dd58b975f..b96ea8fc4b49f06d91d1f97bcdaa2f3fc16e50ca 100644 (file)
@@ -181,22 +181,32 @@ LPWSTR CombineURL(LPCWSTR baseUrl, LPCWSTR url)
         {
             // validate protocol header
             const wchar_t *start = url;
-            while( start != end ) {
-                wchar_t c = towlower(*start);
-                if( (c < L'a') || (c > L'z') )
-                    // not a valid protocol header, assume relative URL
-                    goto relativeurl;
-                ++start;
-            }
-            /* we have a protocol header, therefore URL is absolute */
-            UINT len = wcslen(url);
-            wchar_t *href = (LPWSTR)CoTaskMemAlloc((len+1)*sizeof(wchar_t));
-            if( href )
+            wchar_t c = *start;
+            if( iswalpha(c) )
             {
-                memcpy(href, url, len*sizeof(wchar_t));
-                href[len] = L'\0';
+                ++start;
+                while( start != end )
+                {
+                    c = *start;
+                    if( ! (iswalnum(c)
+                       || (L'-' == c)
+                       || (L'+' == c)
+                       || (L'.' == c)
+                       || (L'/' == c)) ) /* VLC uses / to allow user to specify a demuxer */
+                        // not valid protocol header, assume relative URL
+                        goto relativeurl;
+                    ++start;
+                }
+                /* we have a protocol header, therefore URL is absolute */
+                UINT len = wcslen(url);
+                wchar_t *href = (LPWSTR)CoTaskMemAlloc((len+1)*sizeof(wchar_t));
+                if( href )
+                {
+                    memcpy(href, url, len*sizeof(wchar_t));
+                    href[len] = L'\0';
+                }
+                return href;
             }
-            return href;
         }
 
 relativeurl:
@@ -263,7 +273,7 @@ relativeurl:
                     return href;
                 }
 
-                /* find last path component and replace it */ 
+                /* find last path component and replace it */
                 while( L'/' != *pathend )
                     --pathend;
 
@@ -290,7 +300,7 @@ relativeurl:
                         url = ++p;
                         continue;
                     }
-                    if( L'.' != *p ) 
+                    if( L'.' != *p )
                         break;
                     ++p;
                     if( L'\0' == *p )
@@ -299,7 +309,7 @@ relativeurl:
                     }
                     else
                     {
-                        if( L'/' != *p ) 
+                        if( L'/' != *p )
                             break;
                         /* relative url starts with '../' */
                         ++p;