[PATCH 0/1] MR10700: iertutil: Fix wrong host type for Punycode-encoded hostnames.
It's something that I encountered when I was working on IUriRuntimeClass. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/10700
From: Zhiyi Zhang <zzhang@codeweavers.com> --- dlls/iertutil/uri.c | 8 ++++++++ dlls/urlmon/tests/uri.c | 27 +++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/dlls/iertutil/uri.c b/dlls/iertutil/uri.c index 38408c4baf5..a5ab3dfae4f 100644 --- a/dlls/iertutil/uri.c +++ b/dlls/iertutil/uri.c @@ -1360,12 +1360,20 @@ static BOOL parse_reg_name(const WCHAR **ptr, parse_data *data, DWORD extras) { data->host_type = Uri_HOST_DNS; + /* If it contains Unicode, then it's an IDN */ for(i = 0; i < data->host_len; i++) { if(!is_ascii(data->host[i])) { data->host_type = Uri_HOST_IDN; break; } } + + /* If it's Punycode-encoded, then it's also an IDN */ + if(data->host_type == Uri_HOST_DNS) { + DWORD decoded_length = IdnToUnicode(0, data->host, data->host_len, NULL, 0); + if(decoded_length > 0 && decoded_length != data->host_len) + data->host_type = Uri_HOST_IDN; + } } TRACE("(%p %p %lx): Parsed reg-name. host=%s len=%ld type=%d\n", ptr, data, extras, diff --git a/dlls/urlmon/tests/uri.c b/dlls/urlmon/tests/uri.c index 4a0ae350b33..40c1692522f 100644 --- a/dlls/urlmon/tests/uri.c +++ b/dlls/urlmon/tests/uri.c @@ -5653,6 +5653,33 @@ static const uri_properties uri_tests[] = { {URLZONE_INVALID,E_NOTIMPL,FALSE} } }, + /* Punycode-encoded host with Uri_CREATE_NO_CANONICALIZE */ + { + "http://xn--0zwm56d.EXAMPLE.com/", Uri_CREATE_NO_CANONICALIZE, S_OK, FALSE, 0, + { + {"http://xn--0zwm56d.EXAMPLE.com/",S_OK,FALSE}, + {"xn--0zwm56d.EXAMPLE.com",S_OK,FALSE}, + {"http://xn--0zwm56d.EXAMPLE.com/",S_OK,FALSE}, + {"EXAMPLE.com",S_OK,FALSE}, + {"",S_FALSE,FALSE}, + {"",S_FALSE,FALSE}, + {"xn--0zwm56d.EXAMPLE.com",S_OK,FALSE}, + {"",S_FALSE,FALSE}, + {"/",S_OK,FALSE}, + {"/",S_OK,FALSE}, + {"",S_FALSE,FALSE}, + {"http://xn--0zwm56d.EXAMPLE.com/",S_OK,FALSE}, + {"http",S_OK,FALSE}, + {"",S_FALSE,FALSE}, + {"",S_FALSE,FALSE,NULL}, + }, + { + {Uri_HOST_IDN,S_OK,FALSE}, + {80,S_OK,FALSE}, + {URL_SCHEME_HTTP,S_OK,FALSE}, + {URLZONE_INVALID,E_NOTIMPL,FALSE} + } + }, /* Multiple flags */ { "http://username:password@winehq.org/index.html?query=value#fragment", 0, S_OK, FALSE, Uri_DISPLAY_NO_FRAGMENT | Uri_DISPLAY_IDN_HOST, { -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10700
This merge request was approved by Jacek Caban. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/10700
participants (3)
-
Jacek Caban (@jacek) -
Zhiyi Zhang -
Zhiyi Zhang (@zhiyi)