diff --git a/dlls/mshtml/protocol.c b/dlls/mshtml/protocol.c
index dad93ba2b1c..456c3fd8d31 100644
--- a/dlls/mshtml/protocol.c
+++ b/dlls/mshtml/protocol.c
@@ -865,8 +865,20 @@ static HRESULT WINAPI ResProtocolInfo_ParseUrl(IInternetProtocolInfo *iface, LPC
len = SearchPathW(NULL, file_part, NULL, sizeof(full_path)/sizeof(WCHAR), full_path, NULL);
if(!len) {
- WARN("Could not find file %s\n", debugstr_w(file_part));
- return MK_E_SYNTAX;
+ HMODULE module;
+
+ /* SearchPath does not work well with winelib files (like our test executable),
+ * so we also try to load the library here */
+ module = LoadLibraryExW(file_part, NULL, LOAD_LIBRARY_AS_DATAFILE);
+ if(!module) {
+ WARN("Could not find file %s\n", debugstr_w(file_part));
+ return MK_E_SYNTAX;
+ }
+
+ len = GetModuleFileNameW(module, full_path, sizeof(full_path)/sizeof(WCHAR));
+ FreeLibrary(module);
+ if(!len)
+ return E_FAIL;
}
size = sizeof(wszFile)/sizeof(WCHAR) + len + 1;
diff --git a/dlls/mshtml/tests/protocol.c b/dlls/mshtml/tests/protocol.c
index 75049279077..07f424fde74 100644
--- a/dlls/mshtml/tests/protocol.c
+++ b/dlls/mshtml/tests/protocol.c
@@ -315,6 +315,8 @@ static void test_res_protocol(void)
{'r','e','s',':','/','/','x','x','.','d','l','l','/','b','l','a','n','k','.','h','t','m',0};
static const WCHAR wrong_url5[] =
{'r','e','s',':','/','/','s','h','t','m','l','.','d','l','l','/','b','l','a','n','k','.','h','t','m',0};
+ static const WCHAR wrong_url6[] =
+ {'r','e','s',':','/','/','c',':','\\','d','i','r','\\','f','i','l','e','.','d','l','l','/','b','l','a','n','k','.','h','t','m',0};
static const WCHAR mshtml_dllW[] = {'m','s','h','t','m','l','.','d','l','l',0};
hres = CoGetClassObject(&CLSID_ResProtocol, CLSCTX_INPROC_SERVER, NULL, &IID_IUnknown, (void**)&unk);
@@ -366,6 +368,10 @@ static void test_res_protocol(void)
sizeof(buf)/sizeof(buf[0]), &size, 0);
ok(hres == MK_E_SYNTAX, "ParseUrl failed: %08x, expected MK_E_SYNTAX\n", hres);
+ hres = IInternetProtocolInfo_ParseUrl(protocol_info, wrong_url6, PARSE_SECURITY_URL, 0, buf,
+ sizeof(buf)/sizeof(buf[0]), &size, 0);
+ ok(hres == MK_E_SYNTAX, "ParseUrl failed: %08x, expected MK_E_SYNTAX\n", hres);
+
size = 0xdeadbeef;
buf[0] = '?';
hres = IInternetProtocolInfo_ParseUrl(protocol_info, blank_url, PARSE_DOMAIN, 0, buf,