diff --git a/dlls/mshtml/protocol.c b/dlls/mshtml/protocol.c
index c8f8d08243d..2499db4fbd5 100644
--- a/dlls/mshtml/protocol.c
+++ b/dlls/mshtml/protocol.c
@@ -594,9 +594,9 @@ static HRESULT WINAPI ResProtocol_Start(IInternetProtocol *iface, LPCWSTR szUrl,
DWORD grfPI, HANDLE_PTR dwReserved)
{
ResProtocol *This = ResProtocol_from_IInternetProtocol(iface);
+ WCHAR *url_dll, *url_file, *url, *mime, *res_type = (LPWSTR)RT_HTML, *ptr;
DWORD grfBINDF = 0, len;
BINDINFO bindinfo;
- LPWSTR url_dll, url_file, url, mime, res_type = (LPWSTR)RT_HTML;
HMODULE hdll;
HRSRC src;
HRESULT hres;
@@ -646,6 +646,12 @@ static HRESULT WINAPI ResProtocol_Start(IInternetProtocol *iface, LPCWSTR szUrl,
res_type = MAKEINTRESOURCEW(RT_HTML);
}
+ /* Ignore query and hash parts. */
+ if((ptr = strchrW(url_file, '?')))
+ *ptr = 0;
+ if((ptr = strchrW(url_file, '#')))
+ *ptr = 0;
+
hdll = LoadLibraryExW(url_dll, NULL, LOAD_LIBRARY_AS_DATAFILE);
if(!hdll) {
WARN("Could not open dll: %s\n", debugstr_w(url_dll));
diff --git a/dlls/mshtml/tests/protocol.c b/dlls/mshtml/tests/protocol.c
index 3c3b58b02ad..49743d52082 100644
--- a/dlls/mshtml/tests/protocol.c
+++ b/dlls/mshtml/tests/protocol.c
@@ -601,6 +601,13 @@ static void test_res_protocol(void)
test_res_url("/jstest.html");
test_res_url("/Test/res.html");
test_res_url("/test/dir/dir2/res.html");
+
+ if(GetProcAddress(LoadLibraryA("urlmon.dll"), "CreateUri")) {
+ test_res_url("/test/dir/dir2/res.html?query_part");
+ test_res_url("/test/dir/dir2/res.html#hash_part");
+ }else {
+ win_skip("IUri not supported\n");
+ }
}
static void do_test_about_protocol(IClassFactory *factory, DWORD bf)