[PATCH v4 1/3] mshtml: for res:// URLs, numeric resource type ids don't need a leading '#'
Damjan Jovanovic
damjan.jov at gmail.com
Tue Apr 21 10:48:22 CDT 2020
Numeric resource type ids are either specified as the number
with MAKEINTRESOURCEW(), or as a string prefixed by '#'.
But mshtml's res:// protocol also allows the resource type
id to be a numeric string without the '#' prefix.
Try 4 uses !*endpoint to check for success in wcstol()
instead of endpoint == s+lstrlenW(s).
Signed-off-by: Damjan Jovanovic <damjan.jov at gmail.com>
---
dlls/mshtml/protocol.c | 27 +++++++++++++++++++--------
dlls/mshtml/tests/protocol.c | 7 +++++++
2 files changed, 26 insertions(+), 8 deletions(-)
-------------- next part --------------
diff --git a/dlls/mshtml/protocol.c b/dlls/mshtml/protocol.c
index 0f06896c49..741a4277ca 100644
--- a/dlls/mshtml/protocol.c
+++ b/dlls/mshtml/protocol.c
@@ -543,6 +543,7 @@ static HRESULT WINAPI ResProtocol_Start(IInternetProtocol *iface, LPCWSTR szUrl,
DWORD grfBINDF = 0, len;
BINDINFO bindinfo;
HMODULE hdll;
+ DWORD res_type_id = MAXDWORD;
HRSRC src;
HRESULT hres;
@@ -585,7 +586,11 @@ static HRESULT WINAPI ResProtocol_Start(IInternetProtocol *iface, LPCWSTR szUrl,
*res_type++ = 0;
if ((url_file = wcschr(res_type, '/'))) {
+ LPWSTR endpoint = NULL;
*url_file++ = 0;
+ res_type_id = wcstol(res_type, &endpoint, 10);
+ if(*endpoint)
+ res_type_id = MAXDWORD;
}else {
url_file = res_type;
res_type = (LPWSTR)RT_HTML;
@@ -608,21 +613,27 @@ 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 && res_type_id != MAXDWORD)
+ src = FindResourceW(hdll, url_file, (LPCWSTR)res_type_id);
+
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) {
- WARN("Could not find resource\n");
- IInternetProtocolSink_ReportResult(pOIProtSink,
- HRESULT_FROM_WIN32(GetLastError()), 0, NULL);
- heap_free(url);
- return HRESULT_FROM_WIN32(GetLastError());
+ if(!src && res_type_id != MAXDWORD)
+ src = FindResourceW(hdll, MAKEINTRESOURCEW(file_id), (LPCWSTR)res_type_id);
}
}
+ if(!src) {
+ WARN("Could not find resource\n");
+ IInternetProtocolSink_ReportResult(pOIProtSink,
+ HRESULT_FROM_WIN32(GetLastError()), 0, NULL);
+ heap_free(url);
+ return HRESULT_FROM_WIN32(GetLastError());
+ }
+
if(This->data) {
WARN("data already loaded\n");
heap_free(This->data);
diff --git a/dlls/mshtml/tests/protocol.c b/dlls/mshtml/tests/protocol.c
index ba767d21c6..75063f5ecf 100644
--- a/dlls/mshtml/tests/protocol.c
+++ b/dlls/mshtml/tests/protocol.c
@@ -596,6 +596,13 @@ static void test_res_protocol(void)
IUnknown_Release(unk);
+ test_res_url("/blank.html");
+ test_res_url("/123");
+ test_res_url("/#23/blank.html");
+ test_res_url("/#23/123");
+ test_res_url("/23/blank.html");
+ test_res_url("/23/123");
+
test_res_url("/jstest.html");
test_res_url("/Test/res.html");
test_res_url("/test/dir/dir2/res.html");
More information about the wine-devel
mailing list