urlmon: Strip forward and back slashes when using the file: protocol.

This commit is contained in:
Alistair Leslie-Hughes 2010-04-20 21:31:29 +10:00 committed by Alexandre Julliard
parent 9eaab2cec1
commit c79c849479
2 changed files with 19 additions and 1 deletions

View file

@ -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++;

View file

@ -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;