[PATCH] Strip forward and back slashes when using the file: protocol

Alistair Leslie-Hughes leslie_alistair at hotmail.com
Tue Apr 20 06:31:29 CDT 2010


---
 dlls/urlmon/file.c           |    5 ++++-
 dlls/urlmon/tests/protocol.c |   15 +++++++++++++++
 2 files changed, 19 insertions(+), 1 deletions(-)

diff --git a/dlls/urlmon/file.c b/dlls/urlmon/file.c
index ed4802b..a517d94 100644
--- a/dlls/urlmon/file.c
+++ b/dlls/urlmon/file.c
@@ -141,7 +141,10 @@ static HRESULT WINAPI FileProtocol_Start(IInternetProtocol *iface, LPCWSTR szUrl
         IInternetProtocolSink_ReportProgress(pOIProtSink, BINDSTATUS_SENDINGREQUEST, &null_char);
 
         file_name = url+sizeof(wszFile)/sizeof(WCHAR);
-        if(file_name[0] == '/' && file_name[1] == '/')
+
+        /* Strip both forward and back slashes */
+        if( (file_name[0] == '/' && file_name[1] == '/') ||
+            (file_name[0] == '\\' && file_name[1] == '\\'))
             file_name += 2;
         if(*file_name == '/')
             file_name++;
diff --git a/dlls/urlmon/tests/protocol.c b/dlls/urlmon/tests/protocol.c
index d54d00d..ba0c32c 100644
--- a/dlls/urlmon/tests/protocol.c
+++ b/dlls/urlmon/tests/protocol.c
@@ -2241,6 +2241,7 @@ static void test_file_protocol(void) {
     static const WCHAR wszFile[] = {'f','i','l','e',':',0};
     static const WCHAR wszFile2[] = {'f','i','l','e',':','/','/',0};
     static const WCHAR wszFile3[] = {'f','i','l','e',':','/','/','/',0};
+    static const WCHAR wszFile4[] = {'f','i','l','e',':','\\','\\',0};
     static const char html_doc[] = "<HTML></HTML>";
 
     trace("Testing file protocol...\n");
@@ -2306,6 +2307,20 @@ static void test_file_protocol(void) {
     bindf = BINDF_FROMURLMON;
     test_file_protocol_url(buf);
 
+    memcpy(buf, wszFile4, sizeof(wszFile4));
+    len = GetCurrentDirectoryW(sizeof(file_name_buf)/sizeof(WCHAR), file_name_buf);
+    file_name_buf[len++] = '\\';
+    memcpy(file_name_buf+len, wszIndexHtml, sizeof(wszIndexHtml));
+    lstrcpyW(buf+sizeof(wszFile4)/sizeof(WCHAR)-1, file_name_buf);
+    file_name = file_name_buf;
+    bindf = 0;
+    test_file_protocol_url(buf);
+    bindf = BINDF_FROMURLMON;
+    test_file_protocol_url(buf);
+
+    buf[sizeof(wszFile4)/sizeof(WCHAR)] = '|';
+    test_file_protocol_url(buf);
+
     DeleteFileW(wszIndexHtml);
 
     bindf = 0;
-- 
1.6.2.5


--------------030802020305030601090107--



More information about the wine-patches mailing list