From: Zhiyi Zhang <zzhang@codeweavers.com> --- dlls/iertutil/uri.c | 6 ++--- dlls/urlmon/tests/uri.c | 52 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+), 3 deletions(-) diff --git a/dlls/iertutil/uri.c b/dlls/iertutil/uri.c index e9410f79446..7a32b6f0f4e 100644 --- a/dlls/iertutil/uri.c +++ b/dlls/iertutil/uri.c @@ -2427,7 +2427,7 @@ static DWORD canonicalize_path_hierarchical(const WCHAR *path, DWORD path_len, U } } - if(!is_file && *path && *path != '/') { + if(!is_file && *path && *path != '/' && *path != '\\') { /* Prepend a '/' to the path if it doesn't have one. */ if(ret_path) ret_path[len] = '/'; @@ -2755,7 +2755,7 @@ static BOOL canonicalize_query(const parse_data *data, Uri *uri, DWORD flags, BO continue; } } - } else if(known_scheme && is_ascii(*ptr) && !is_unreserved(*ptr) && !is_reserved(*ptr)) { + } else if(known_scheme && is_ascii(*ptr) && !is_unreserved(*ptr) && !is_reserved(*ptr) && *ptr != '\\') { if(!(flags & Uri_CREATE_NO_ENCODE_FORBIDDEN_CHARACTERS) && !(flags & Uri_CREATE_NO_DECODE_EXTRA_INFO)) { if(!computeOnly) @@ -2805,7 +2805,7 @@ static BOOL canonicalize_fragment(const parse_data *data, Uri *uri, DWORD flags, continue; } } - } else if(known_scheme && is_ascii(*ptr) && !is_unreserved(*ptr) && !is_reserved(*ptr)) { + } else if(known_scheme && is_ascii(*ptr) && !is_unreserved(*ptr) && !is_reserved(*ptr) && *ptr != '\\') { if(!(flags & Uri_CREATE_NO_ENCODE_FORBIDDEN_CHARACTERS) && !(flags & Uri_CREATE_NO_DECODE_EXTRA_INFO)) { if(!computeOnly) diff --git a/dlls/urlmon/tests/uri.c b/dlls/urlmon/tests/uri.c index cf285e72e00..4869c174d05 100644 --- a/dlls/urlmon/tests/uri.c +++ b/dlls/urlmon/tests/uri.c @@ -4036,6 +4036,58 @@ static const uri_properties uri_tests[] = { {URLZONE_INVALID,E_NOTIMPL,FALSE} } }, + /* '\' are converted to '/' for known schemes */ + { "http://a\\b//c\\d?e\\f#g\\h", 0, S_OK, FALSE, 0, + { + {"http://a/b//c/d?e\\f#g\\h",S_OK,FALSE}, + {"a",S_OK,FALSE}, + {"http://a/b//c/d?e\\f#g\\h",S_OK,FALSE}, + {"",S_FALSE,FALSE}, + {"",S_FALSE,FALSE}, + {"#g\\h",S_OK,FALSE}, + {"a",S_OK,FALSE}, + {"",S_FALSE,FALSE}, + {"/b//c/d",S_OK,FALSE}, + {"/b//c/d?e\\f",S_OK,FALSE}, + {"?e\\f",S_OK,FALSE}, + {"http://a\\b//c\\d?e\\f#g\\h",S_OK,FALSE}, + {"http",S_OK,FALSE}, + {"",S_FALSE,FALSE}, + {"",S_FALSE,FALSE} + }, + { + {Uri_HOST_DNS,S_OK,FALSE}, + {80,S_OK,FALSE}, + {URL_SCHEME_HTTP,S_OK,FALSE}, + {URLZONE_INVALID,E_NOTIMPL,FALSE} + } + }, + /* '\' are not converted to '/' for unknown schemes */ + { "unknown://a\\b//c\\d?e\\f#g\\h", 0, S_OK, FALSE, 0, + { + {"unknown://a\\b//c\\d?e\\f#g\\h",S_OK,FALSE}, + {"a\\b",S_OK,FALSE}, + {"unknown://a\\b//c\\d?e\\f#g\\h",S_OK,FALSE}, + {"",S_FALSE,FALSE}, + {"",S_FALSE,FALSE}, + {"#g\\h",S_OK,FALSE}, + {"a\\b",S_OK,FALSE}, + {"",S_FALSE,FALSE}, + {"//c\\d",S_OK,FALSE}, + {"//c\\d?e\\f",S_OK,FALSE}, + {"?e\\f",S_OK,FALSE}, + {"unknown://a\\b//c\\d?e\\f#g\\h",S_OK,FALSE}, + {"unknown",S_OK,FALSE}, + {"",S_FALSE,FALSE}, + {"",S_FALSE,FALSE} + }, + { + {Uri_HOST_DNS,S_OK,FALSE}, + {0,S_FALSE,FALSE}, + {URL_SCHEME_UNKNOWN,S_OK,FALSE}, + {URLZONE_INVALID,E_NOTIMPL,FALSE} + } + }, /* Forbidden characters aren't percent encoded. */ { "file:c:\\in^|dex.html", Uri_CREATE_FILE_USE_DOS_PATH, S_OK, FALSE, 0, { -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10542