From: Zhiyi Zhang <zzhang@codeweavers.com> --- dlls/iertutil/uri.c | 8 ++++---- dlls/urlmon/tests/uri.c | 26 ++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/dlls/iertutil/uri.c b/dlls/iertutil/uri.c index 4797e12642f..e9410f79446 100644 --- a/dlls/iertutil/uri.c +++ b/dlls/iertutil/uri.c @@ -1856,9 +1856,9 @@ static BOOL canonicalize_username(const parse_data *data, Uri *uri, DWORD flags, } } else if(is_ascii(*ptr) && !is_reserved(*ptr) && !is_unreserved(*ptr) && *ptr != '\\') { /* Only percent encode forbidden characters if the NO_ENCODE_FORBIDDEN_CHARACTERS flag - * is NOT set. + * is NOT set and the scheme is known. */ - if(!(flags & Uri_CREATE_NO_ENCODE_FORBIDDEN_CHARACTERS)) { + if(!(flags & Uri_CREATE_NO_ENCODE_FORBIDDEN_CHARACTERS) && data->scheme_type != URL_SCHEME_UNKNOWN) { if(!computeOnly) pct_encode_val(*ptr, uri->canon_uri + uri->canon_len); @@ -1914,9 +1914,9 @@ static BOOL canonicalize_password(const parse_data *data, Uri *uri, DWORD flags, } } else if(is_ascii(*ptr) && !is_reserved(*ptr) && !is_unreserved(*ptr) && *ptr != '\\') { /* Only percent encode forbidden characters if the NO_ENCODE_FORBIDDEN_CHARACTERS flag - * is NOT set. + * is NOT set and the scheme is known. */ - if(!(flags & Uri_CREATE_NO_ENCODE_FORBIDDEN_CHARACTERS)) { + if(!(flags & Uri_CREATE_NO_ENCODE_FORBIDDEN_CHARACTERS) && data->scheme_type != URL_SCHEME_UNKNOWN) { if(!computeOnly) pct_encode_val(*ptr, uri->canon_uri + uri->canon_len); diff --git a/dlls/urlmon/tests/uri.c b/dlls/urlmon/tests/uri.c index 598828ccfd5..cf285e72e00 100644 --- a/dlls/urlmon/tests/uri.c +++ b/dlls/urlmon/tests/uri.c @@ -2591,6 +2591,32 @@ static const uri_properties uri_tests[] = { {URLZONE_INVALID,E_NOTIMPL,FALSE} } }, + /* Forbidden characters are never encoded for unknown scheme types. */ + { "unknown://us er:pass word@exam ple.com/pa th?qu ery=val ue#frag ment", 0, S_OK, FALSE, 0, + { + {"unknown://us er:pass word@exam ple.com/pa th?qu ery=val ue#frag ment",S_OK,FALSE}, + {"us er:pass word@exam ple.com",S_OK,FALSE}, + {"unknown://us er:pass word@exam ple.com/pa th?qu ery=val ue#frag ment",S_OK,FALSE}, + {"exam ple.com",S_OK,FALSE}, + {"",S_FALSE,FALSE}, + {"#frag ment",S_OK,FALSE}, + {"exam ple.com",S_OK,FALSE}, + {"pass word",S_OK,FALSE}, + {"/pa th",S_OK,FALSE}, + {"/pa th?qu ery=val ue",S_OK,FALSE}, + {"?qu ery=val ue",S_OK,FALSE}, + {"unknown://us er:pass word@exam ple.com/pa th?qu ery=val ue#frag ment",S_OK,FALSE}, + {"unknown",S_OK,FALSE}, + {"us er:pass word",S_OK,FALSE}, + {"us er",S_OK,FALSE} + }, + { + {Uri_HOST_DNS,S_OK,FALSE}, + {0,S_FALSE,FALSE}, + {URL_SCHEME_UNKNOWN,S_OK,FALSE}, + {URLZONE_INVALID,E_NOTIMPL,FALSE} + } + }, /* Make sure forbidden characters are percent encoded. */ { "http://gov.uk/<|> test<|>", 0, S_OK, FALSE, 0, { -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10542