]> git.sesse.net Git - vlc/commitdiff
URI: when pasring for protocol headers allow for more characters than just alpha
authorDamien Fouilleul <damienf@videolan.org>
Mon, 20 Aug 2007 10:40:36 +0000 (10:40 +0000)
committerDamien Fouilleul <damienf@videolan.org>
Mon, 20 Aug 2007 10:40:36 +0000 (10:40 +0000)
activex/utils.cpp
mozilla/vlcplugin.cpp

index 8750aa1ce2e6749e3e3b9492829a4d2dd58b975f..8cb0b0e08a6ba212e800e2947419d5caefb4afa1 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:
index 05e18f9fa69b396ba52beacbce9f55cb1cb5e79a..24d1f7b2e9ea281a608c14e4970aae152fe2b9dc 100644 (file)
@@ -90,7 +90,7 @@ NPError VlcPlugin::init(int argc, char* const argn[], char* const argv[])
          {
              if( i_type == REG_SZ )
              {
-                 strcat( p_data, "\\plugins" );
+                 strcat( p_data, "\\plugins000" );
                  ppsz_argv[ppsz_argc++] = "--plugin-path";
                  ppsz_argv[ppsz_argc++] = p_data;
              }
@@ -99,7 +99,7 @@ NPError VlcPlugin::init(int argc, char* const argn[], char* const argv[])
     }
     ppsz_argv[ppsz_argc++] = "--no-one-instance";
 
-#if 0
+#if 1
     ppsz_argv[0] = "C:\\Cygwin\\home\\damienf\\vlc-trunk\\vlc";
 #endif
 
@@ -290,15 +290,26 @@ char *VlcPlugin::getAbsoluteURL(const char *url)
         {
             // validate protocol header
             const char *start = url;
-            while( start != end ) {
-                char c = tolower(*start);
-                if( (c < 'a') || (c > 'z') )
-                    // not valid protocol header, assume relative URL
-                    goto relativeurl;
+            char c = *start;
+            if( isalpha(c) )
+            {
                 ++start;
+                while( start != end )
+                {
+                    c  = *start;
+                    if( ! (isalnum(c)
+                       || ('-' == c)
+                       || ('+' == c)
+                       || ('.' == c)
+                       || ('/' == 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 */
+                return strdup(url);
             }
-            /* we have a protocol header, therefore URL is absolute */
-            return strdup(url);
+            // not a valid protocol header, assume relative URL
         }
 
 relativeurl: