[PATCH 0/1] MR585: mshtml: Unescape path before converting it to wide character string in is_gecko_path().
This fixes an issue when the path includes non-ASCII characters. Signed-off-by: Jactry Zeng <jzeng(a)codeweavers.com> -- https://gitlab.winehq.org/wine/wine/-/merge_requests/585
From: Jactry Zeng <jzeng(a)codeweavers.com> This fixes an issue when the path includes non-ASCII characters. Signed-off-by: Jactry Zeng <jzeng(a)codeweavers.com> --- dlls/mshtml/nsembed.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/dlls/mshtml/nsembed.c b/dlls/mshtml/nsembed.c index c7683a6d06d..2918362c9c0 100644 --- a/dlls/mshtml/nsembed.c +++ b/dlls/mshtml/nsembed.c @@ -1285,19 +1285,21 @@ void close_gecko(void) BOOL is_gecko_path(const char *path) { - WCHAR *buf, *ptr; + char unescaped_path[INTERNET_MAX_URL_LENGTH], *ptr; + WCHAR *buf; BOOL ret; - buf = heap_strdupUtoW(path); - if(!buf || lstrlenW(buf) < gecko_path_len) - return FALSE; - - for(ptr = buf; *ptr; ptr++) { + strcpy(unescaped_path, path); + UrlUnescapeA(unescaped_path, NULL, NULL, URL_UNESCAPE_INPLACE); + for(ptr = unescaped_path; *ptr; ptr++) { if(*ptr == '\\') *ptr = '/'; } - UrlUnescapeW(buf, NULL, NULL, URL_UNESCAPE_INPLACE); + buf = heap_strdupUtoW(unescaped_path); + if(!buf || lstrlenW(buf) < gecko_path_len) + return FALSE; + buf[gecko_path_len] = 0; ret = !wcsicmp(buf, gecko_path); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/585
Jacek Caban (@jacek) commented about dlls/mshtml/nsembed.c:
BOOL is_gecko_path(const char *path) { - WCHAR *buf, *ptr; + char unescaped_path[INTERNET_MAX_URL_LENGTH], *ptr; + WCHAR *buf; BOOL ret;
- buf = heap_strdupUtoW(path); - if(!buf || lstrlenW(buf) < gecko_path_len) - return FALSE; - - for(ptr = buf; *ptr; ptr++) { + strcpy(unescaped_path, path); + UrlUnescapeA(unescaped_path, NULL, NULL, URL_UNESCAPE_INPLACE);
I think that path is in UTF8 (unless it's specified otherwise by NewURI caller; we don't handle that yet, but I think Gecko doesn't use it another way anyway), while UrlUnescapeA will use CP_ACP. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/585#note_5684
participants (3)
-
Jacek Caban (@jacek) -
Jactry Zeng -
Jactry Zeng (@jactry)