From: Gabriel Ivăncescu gabrielopcode@gmail.com
Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com --- dlls/urlmon/file.c | 10 ++++------ dlls/urlmon/tests/protocol.c | 18 +++++++++++------- 2 files changed, 15 insertions(+), 13 deletions(-)
diff --git a/dlls/urlmon/file.c b/dlls/urlmon/file.c index da71991129b..d0778c5c69e 100644 --- a/dlls/urlmon/file.c +++ b/dlls/urlmon/file.c @@ -309,14 +309,12 @@ static HRESULT WINAPI FileProtocol_StartEx(IInternetProtocolEx *iface, IUri *pUr return report_result(pOIProtSink, hres, 0); }
+ /* If path contains fragment part, ignore it. */ + if((ptr = wcschr(path, '#'))) + *ptr = 0; + file_handle = CreateFileW(path, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); - if(file_handle == INVALID_HANDLE_VALUE && (ptr = wcsrchr(path, '#'))) { - /* If path contains fragment part, try without it. */ - *ptr = 0; - file_handle = CreateFileW(path, GENERIC_READ, FILE_SHARE_READ, NULL, - OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); - } if(file_handle == INVALID_HANDLE_VALUE) return report_result(pOIProtSink, INET_E_RESOURCE_NOT_FOUND, GetLastError());
diff --git a/dlls/urlmon/tests/protocol.c b/dlls/urlmon/tests/protocol.c index 85615eec7e3..a7692319c35 100644 --- a/dlls/urlmon/tests/protocol.c +++ b/dlls/urlmon/tests/protocol.c @@ -3145,25 +3145,29 @@ static void test_file_protocol(void) { buf[ARRAY_SIZE(L"file:\\")] = '|'; test_file_protocol_url(buf);
- /* Fragment part of URL is skipped if the file doesn't exist. */ - lstrcatW(buf, L"#frag"); + /* Fragment part of URL is always skipped. */ + lstrcatW(buf, L"#frag#abc"); + test_file_protocol_url(buf); + + file = CreateFileW(L"index.html#frag#abc", GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, + FILE_ATTRIBUTE_NORMAL, NULL); + ok(file != INVALID_HANDLE_VALUE, "CreateFile failed\n"); + WriteFile(file, "DEAD", 3, &size, NULL); + CloseHandle(file); + test_file_protocol_url(buf);
- /* Fragment part is considered a part of the file name, if the file exists. */ - len = lstrlenW(file_name_buf); - lstrcpyW(file_name_buf+len, L"#frag"); file = CreateFileW(L"index.html", GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); ok(file != INVALID_HANDLE_VALUE, "CreateFile failed\n"); WriteFile(file, "XXX", 3, &size, NULL); CloseHandle(file); - file_name_buf[len] = 0;
file_with_hash = TRUE; test_file_protocol_url(buf);
+ DeleteFileW(L"index.html#frag#abc"); DeleteFileW(L"index.html"); - DeleteFileW(file_name_buf);
bindf = 0; test_file_protocol_fail();