Damjan Jovanovic : mshtml: Support implicit RT_FILE resource type in res protocol.
Alexandre Julliard
julliard at winehq.org
Fri Apr 24 15:11:39 CDT 2020
Module: wine
Branch: master
Commit: 3e8bca0eb4f3f2c9b3bbf9fc634242512f8759b1
URL: https://source.winehq.org/git/wine.git/?a=commit;h=3e8bca0eb4f3f2c9b3bbf9fc634242512f8759b1
Author: Damjan Jovanovic <damjan.jov at gmail.com>
Date: Fri Apr 24 18:37:44 2020 +0200
mshtml: Support implicit RT_FILE resource type in res protocol.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=47999
Signed-off-by: Damjan Jovanovic <damjan.jov at gmail.com>
Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/mshtml/protocol.c | 13 +++++++++----
dlls/mshtml/tests/protocol.c | 32 ++++++++++++++++++++++++++++++++
dlls/mshtml/tests/rsrc.rc | 3 +++
3 files changed, 44 insertions(+), 4 deletions(-)
diff --git a/dlls/mshtml/protocol.c b/dlls/mshtml/protocol.c
index 8677030c35..a311d648f2 100644
--- a/dlls/mshtml/protocol.c
+++ b/dlls/mshtml/protocol.c
@@ -539,7 +539,7 @@ static HRESULT WINAPI ResProtocol_Start(IInternetProtocol *iface, LPCWSTR szUrl,
DWORD grfPI, HANDLE_PTR dwReserved)
{
InternetProtocol *This = impl_from_IInternetProtocol(iface);
- WCHAR *url_dll, *url_file, *url, *mime, *res_type = (LPWSTR)RT_HTML, *ptr;
+ WCHAR *url_dll, *url_file, *url, *mime, *res_type, *alt_res_type = NULL, *ptr;
DWORD grfBINDF = 0, len;
BINDINFO bindinfo;
HMODULE hdll;
@@ -593,7 +593,8 @@ static HRESULT WINAPI ResProtocol_Start(IInternetProtocol *iface, LPCWSTR szUrl,
res_type = MAKEINTRESOURCEW(res_type_id);
}else {
url_file = res_type;
- res_type = (LPWSTR)RT_HTML;
+ res_type = MAKEINTRESOURCEW(RT_HTML);
+ alt_res_type = MAKEINTRESOURCEW(2110 /* RT_FILE */);
}
/* Ignore query and hash parts. */
@@ -613,12 +614,16 @@ static HRESULT WINAPI ResProtocol_Start(IInternetProtocol *iface, LPCWSTR szUrl,
TRACE("trying to find resource type %s, name %s\n", debugstr_w(res_type), debugstr_w(url_file));
src = FindResourceW(hdll, url_file, res_type);
+ if(!src && alt_res_type)
+ src = FindResourceW(hdll, url_file, alt_res_type);
if(!src) {
LPWSTR endpoint = NULL;
DWORD file_id = wcstol(url_file, &endpoint, 10);
- if(endpoint == url_file+lstrlenW(url_file))
+ if(!*endpoint) {
src = FindResourceW(hdll, MAKEINTRESOURCEW(file_id), res_type);
-
+ if(!src && alt_res_type)
+ src = FindResourceW(hdll, MAKEINTRESOURCEW(file_id), alt_res_type);
+ }
if(!src) {
WARN("Could not find resource\n");
IInternetProtocolSink_ReportResult(pOIProtSink,
diff --git a/dlls/mshtml/tests/protocol.c b/dlls/mshtml/tests/protocol.c
index 75063f5ecf..600ec72e16 100644
--- a/dlls/mshtml/tests/protocol.c
+++ b/dlls/mshtml/tests/protocol.c
@@ -262,6 +262,30 @@ static void protocol_start(IInternetProtocol *protocol, const WCHAR *url)
CHECK_CALLED(ReportResult);
}
+static void test_res_url_fail(const WCHAR *url_suffix)
+{
+ WCHAR url[INTERNET_MAX_URL_LENGTH];
+ IInternetProtocol *protocol;
+ HRESULT hres;
+
+ wcscpy(url, res_url_base);
+ wcscat(url, url_suffix);
+
+ hres = CoCreateInstance(&CLSID_ResProtocol, NULL, CLSCTX_INPROC_SERVER, &IID_IInternetProtocol, (void**)&protocol);
+ ok(hres == S_OK, "Could not create ResProtocol instance: %08x\n", hres);
+
+ SET_EXPECT(GetBindInfo);
+ SET_EXPECT(ReportResult);
+ expect_hr_win32err = TRUE;
+ hres = IInternetProtocol_Start(protocol, url, &protocol_sink, &bind_info, 0, 0);
+ ok(HRESULT_FACILITY(hres) == FACILITY_WIN32,
+ "%s: expected win32 error, got: %08x\n", debugstr_w(url_suffix), hres);
+ CHECK_CALLED(GetBindInfo);
+ CHECK_CALLED(ReportResult);
+
+ IInternetProtocol_Release(protocol);
+}
+
static void test_res_url(const char *url_suffix)
{
WCHAR url[INTERNET_MAX_URL_LENGTH];
@@ -604,6 +628,14 @@ static void test_res_protocol(void)
test_res_url("/23/123");
test_res_url("/jstest.html");
+ test_res_url("/jstest-rtfile.html");
+ test_res_url("/#2110/jstest-rtfile.html");
+ test_res_url("/2110/jstest-rtfile.html");
+
+ test_res_url_fail(L"/doesntexist/jstest-rtfile.html");
+ test_res_url_fail(L"/2/jstest-rtfile.html");
+ test_res_url_fail(L"/23/jstest-rtfile.html"); /* no fallback from explicit RT_HTML */
+
test_res_url("/Test/res.html");
test_res_url("/test/dir/dir2/res.html");
diff --git a/dlls/mshtml/tests/rsrc.rc b/dlls/mshtml/tests/rsrc.rc
index 05bc836ac6..12e95b7456 100644
--- a/dlls/mshtml/tests/rsrc.rc
+++ b/dlls/mshtml/tests/rsrc.rc
@@ -28,6 +28,9 @@ asyncscriptload.js HTML "asyncscriptload.js"
/* @makedep: jstest.html */
jstest.html HTML "jstest.html"
+/* @makedep: jstest.html */
+jstest-rtfile.html 2110 "jstest.html"
+
/* @makedep: vbtest.html */
vbtest.html HTML "vbtest.html"
More information about the wine-cvs
mailing list