Commit ac066d3e authored by Zhiyi Zhang's avatar Zhiyi Zhang Committed by Alexandre Julliard

urlmon: Do not canonicalize Unicode characters.

parent b29157e1
...@@ -357,6 +357,11 @@ static inline BOOL is_slash(WCHAR c) ...@@ -357,6 +357,11 @@ static inline BOOL is_slash(WCHAR c)
return c == '/' || c == '\\'; return c == '/' || c == '\\';
} }
static inline BOOL is_ascii(WCHAR c)
{
return c < 0x80;
}
static BOOL is_default_port(URL_SCHEME scheme, DWORD port) { static BOOL is_default_port(URL_SCHEME scheme, DWORD port) {
DWORD i; DWORD i;
...@@ -2164,7 +2169,7 @@ static BOOL canonicalize_username(const parse_data *data, Uri *uri, DWORD flags, ...@@ -2164,7 +2169,7 @@ static BOOL canonicalize_username(const parse_data *data, Uri *uri, DWORD flags,
continue; continue;
} }
} }
} else if(!is_reserved(*ptr) && !is_unreserved(*ptr) && *ptr != '\\') { } else if(is_ascii(*ptr) && !is_reserved(*ptr) && !is_unreserved(*ptr) && *ptr != '\\') {
/* Only percent encode forbidden characters if the NO_ENCODE_FORBIDDEN_CHARACTERS flag /* Only percent encode forbidden characters if the NO_ENCODE_FORBIDDEN_CHARACTERS flag
* is NOT set. * is NOT set.
*/ */
...@@ -2222,7 +2227,7 @@ static BOOL canonicalize_password(const parse_data *data, Uri *uri, DWORD flags, ...@@ -2222,7 +2227,7 @@ static BOOL canonicalize_password(const parse_data *data, Uri *uri, DWORD flags,
continue; continue;
} }
} }
} else if(!is_reserved(*ptr) && !is_unreserved(*ptr) && *ptr != '\\') { } else if(is_ascii(*ptr) && !is_reserved(*ptr) && !is_unreserved(*ptr) && *ptr != '\\') {
/* Only percent encode forbidden characters if the NO_ENCODE_FORBIDDEN_CHARACTERS flag /* Only percent encode forbidden characters if the NO_ENCODE_FORBIDDEN_CHARACTERS flag
* is NOT set. * is NOT set.
*/ */
...@@ -2357,7 +2362,7 @@ static BOOL canonicalize_reg_name(const parse_data *data, Uri *uri, ...@@ -2357,7 +2362,7 @@ static BOOL canonicalize_reg_name(const parse_data *data, Uri *uri,
if(!computeOnly) if(!computeOnly)
uri->canon_uri[uri->canon_len] = *ptr; uri->canon_uri[uri->canon_len] = *ptr;
++uri->canon_len; ++uri->canon_len;
} else if(!(flags & Uri_CREATE_NO_ENCODE_FORBIDDEN_CHARACTERS) && } else if(!(flags & Uri_CREATE_NO_ENCODE_FORBIDDEN_CHARACTERS) && is_ascii(*ptr) &&
!is_unreserved(*ptr) && !is_reserved(*ptr) && known_scheme) { !is_unreserved(*ptr) && !is_reserved(*ptr) && known_scheme) {
if(!computeOnly) { if(!computeOnly) {
pct_encode_val(*ptr, uri->canon_uri+uri->canon_len); pct_encode_val(*ptr, uri->canon_uri+uri->canon_len);
...@@ -2927,7 +2932,7 @@ static DWORD canonicalize_path_hierarchical(const WCHAR *path, DWORD path_len, U ...@@ -2927,7 +2932,7 @@ static DWORD canonicalize_path_hierarchical(const WCHAR *path, DWORD path_len, U
len++; len++;
do_default_action = FALSE; do_default_action = FALSE;
} }
} else if(known_scheme && !is_res && !is_unreserved(*ptr) && !is_reserved(*ptr) && } else if(known_scheme && !is_res && is_ascii(*ptr) && !is_unreserved(*ptr) && !is_reserved(*ptr) &&
(!(flags & Uri_CREATE_NO_ENCODE_FORBIDDEN_CHARACTERS) || is_file)) { (!(flags & Uri_CREATE_NO_ENCODE_FORBIDDEN_CHARACTERS) || is_file)) {
if(!is_file || !(flags & Uri_CREATE_FILE_USE_DOS_PATH)) { if(!is_file || !(flags & Uri_CREATE_FILE_USE_DOS_PATH)) {
/* Escape the forbidden character. */ /* Escape the forbidden character. */
...@@ -3053,7 +3058,7 @@ static BOOL canonicalize_path_opaque(const parse_data *data, Uri *uri, DWORD fla ...@@ -3053,7 +3058,7 @@ static BOOL canonicalize_path_opaque(const parse_data *data, Uri *uri, DWORD fla
} }
} else if(is_mk && *ptr == ':' && ptr + 1 < data->path + data->path_len && *(ptr + 1) == ':') { } else if(is_mk && *ptr == ':' && ptr + 1 < data->path + data->path_len && *(ptr + 1) == ':') {
flags &= ~Uri_CREATE_FILE_USE_DOS_PATH; flags &= ~Uri_CREATE_FILE_USE_DOS_PATH;
} else if(known_scheme && !is_unreserved(*ptr) && !is_reserved(*ptr) && } else if(known_scheme && is_ascii(*ptr) && !is_unreserved(*ptr) && !is_reserved(*ptr) &&
!(flags & Uri_CREATE_NO_ENCODE_FORBIDDEN_CHARACTERS)) { !(flags & Uri_CREATE_NO_ENCODE_FORBIDDEN_CHARACTERS)) {
if(!(is_file && (flags & Uri_CREATE_FILE_USE_DOS_PATH))) { if(!(is_file && (flags & Uri_CREATE_FILE_USE_DOS_PATH))) {
if(!computeOnly) if(!computeOnly)
...@@ -3207,7 +3212,7 @@ static BOOL canonicalize_query(const parse_data *data, Uri *uri, DWORD flags, BO ...@@ -3207,7 +3212,7 @@ static BOOL canonicalize_query(const parse_data *data, Uri *uri, DWORD flags, BO
continue; continue;
} }
} }
} else if(known_scheme && !is_unreserved(*ptr) && !is_reserved(*ptr)) { } else if(known_scheme && is_ascii(*ptr) && !is_unreserved(*ptr) && !is_reserved(*ptr)) {
if(!(flags & Uri_CREATE_NO_ENCODE_FORBIDDEN_CHARACTERS) && if(!(flags & Uri_CREATE_NO_ENCODE_FORBIDDEN_CHARACTERS) &&
!(flags & Uri_CREATE_NO_DECODE_EXTRA_INFO)) { !(flags & Uri_CREATE_NO_DECODE_EXTRA_INFO)) {
if(!computeOnly) if(!computeOnly)
...@@ -3257,7 +3262,7 @@ static BOOL canonicalize_fragment(const parse_data *data, Uri *uri, DWORD flags, ...@@ -3257,7 +3262,7 @@ static BOOL canonicalize_fragment(const parse_data *data, Uri *uri, DWORD flags,
continue; continue;
} }
} }
} else if(known_scheme && !is_unreserved(*ptr) && !is_reserved(*ptr)) { } else if(known_scheme && is_ascii(*ptr) && !is_unreserved(*ptr) && !is_reserved(*ptr)) {
if(!(flags & Uri_CREATE_NO_ENCODE_FORBIDDEN_CHARACTERS) && if(!(flags & Uri_CREATE_NO_ENCODE_FORBIDDEN_CHARACTERS) &&
!(flags & Uri_CREATE_NO_DECODE_EXTRA_INFO)) { !(flags & Uri_CREATE_NO_DECODE_EXTRA_INFO)) {
if(!computeOnly) if(!computeOnly)
...@@ -6890,7 +6895,7 @@ static HRESULT parse_canonicalize(const Uri *uri, DWORD flags, LPWSTR output, ...@@ -6890,7 +6895,7 @@ static HRESULT parse_canonicalize(const Uri *uri, DWORD flags, LPWSTR output,
len += 3; len += 3;
do_default_action = FALSE; do_default_action = FALSE;
} }
} else if(!is_reserved(*ptr) && !is_unreserved(*ptr)) { } else if(is_ascii(*ptr) && !is_reserved(*ptr) && !is_unreserved(*ptr)) {
if(flags & URL_ESCAPE_UNSAFE) { if(flags & URL_ESCAPE_UNSAFE) {
if(len + 3 < output_len) if(len + 3 < output_len)
pct_encode_val(*ptr, output+len); pct_encode_val(*ptr, output+len);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment