Commit dffc9d31 authored by Thomas Mullaly's avatar Thomas Mullaly Committed by Alexandre Julliard

urlmon: Improve IUri support of res URIs.

parent c067353c
...@@ -3849,6 +3849,110 @@ static const uri_properties uri_tests[] = { ...@@ -3849,6 +3849,110 @@ static const uri_properties uri_tests[] = {
{URL_SCHEME_HTTP,S_OK,FALSE}, {URL_SCHEME_HTTP,S_OK,FALSE},
{URLZONE_INVALID,E_NOTIMPL,FALSE} {URLZONE_INVALID,E_NOTIMPL,FALSE}
} }
},
/* For res URIs the host is everything up until the first '/'. */
{ "res://C:\\dir\\file.exe/DATA/test.html", 0, S_OK, FALSE,
{
{"res://C:\\dir\\file.exe/DATA/test.html",S_OK,FALSE},
{"C:\\dir\\file.exe",S_OK,FALSE},
{"res://C:\\dir\\file.exe/DATA/test.html",S_OK,FALSE},
{"",S_FALSE,FALSE},
{".html",S_OK,FALSE},
{"",S_FALSE,FALSE},
{"C:\\dir\\file.exe",S_OK,FALSE},
{"",S_FALSE,FALSE},
{"/DATA/test.html",S_OK,FALSE},
{"/DATA/test.html",S_OK,FALSE},
{"",S_FALSE,FALSE},
{"res://C:\\dir\\file.exe/DATA/test.html",S_OK,FALSE},
{"res",S_OK,FALSE},
{"",S_FALSE,FALSE},
{"",S_FALSE,FALSE}
},
{
{Uri_HOST_UNKNOWN,S_OK,FALSE},
{0,S_FALSE,FALSE},
{URL_SCHEME_RES,S_OK,FALSE},
{URLZONE_INVALID,E_NOTIMPL,FALSE}
}
},
/* Res URI can contain a '|' in the host name. */
{ "res://c:\\di|r\\file.exe/test", 0, S_OK, FALSE,
{
{"res://c:\\di|r\\file.exe/test",S_OK,FALSE},
{"c:\\di|r\\file.exe",S_OK,FALSE},
{"res://c:\\di|r\\file.exe/test",S_OK,FALSE},
{"",S_FALSE,FALSE},
{"",S_FALSE,FALSE},
{"",S_FALSE,FALSE},
{"c:\\di|r\\file.exe",S_OK,FALSE},
{"",S_FALSE,FALSE},
{"/test",S_OK,FALSE},
{"/test",S_OK,FALSE},
{"",S_FALSE,FALSE},
{"res://c:\\di|r\\file.exe/test",S_OK,FALSE},
{"res",S_OK,FALSE},
{"",S_FALSE,FALSE},
{"",S_FALSE,FALSE}
},
{
{Uri_HOST_UNKNOWN,S_OK,FALSE},
{0,S_FALSE,FALSE},
{URL_SCHEME_RES,S_OK,FALSE},
{URLZONE_INVALID,E_NOTIMPL,FALSE},
}
},
/* Res URIs can have invalid percent encoded values. */
{ "res://c:\\dir%xx\\file.exe/test", 0, S_OK, FALSE,
{
{"res://c:\\dir%xx\\file.exe/test",S_OK,FALSE},
{"c:\\dir%xx\\file.exe",S_OK,FALSE},
{"res://c:\\dir%xx\\file.exe/test",S_OK,FALSE},
{"",S_FALSE,FALSE},
{"",S_FALSE,FALSE},
{"",S_FALSE,FALSE},
{"c:\\dir%xx\\file.exe",S_OK,FALSE},
{"",S_FALSE,FALSE},
{"/test",S_OK,FALSE},
{"/test",S_OK,FALSE},
{"",S_FALSE,FALSE},
{"res://c:\\dir%xx\\file.exe/test",S_OK,FALSE},
{"res",S_OK,FALSE},
{"",S_FALSE,FALSE},
{"",S_FALSE,FALSE}
},
{
{Uri_HOST_UNKNOWN,S_OK,FALSE},
{0,S_FALSE,FALSE},
{URL_SCHEME_RES,S_OK,FALSE},
{URLZONE_INVALID,E_NOTIMPL,FALSE}
}
},
/* Res doesn't get forbidden characters percent encoded in it's path. */
{ "res://c:\\test/tes<|>t", 0, S_OK, FALSE,
{
{"res://c:\\test/tes<|>t",S_OK,FALSE},
{"c:\\test",S_OK,FALSE},
{"res://c:\\test/tes<|>t",S_OK,FALSE},
{"",S_FALSE,FALSE},
{"",S_FALSE,FALSE},
{"",S_FALSE,FALSE},
{"c:\\test",S_OK,FALSE},
{"",S_FALSE,FALSE},
{"/tes<|>t",S_OK,FALSE},
{"/tes<|>t",S_OK,FALSE},
{"",S_FALSE,FALSE},
{"res://c:\\test/tes<|>t",S_OK,FALSE},
{"res",S_OK,FALSE},
{"",S_FALSE,FALSE},
{"",S_FALSE,FALSE}
},
{
{Uri_HOST_UNKNOWN,S_OK,FALSE},
{0,S_FALSE,FALSE},
{URL_SCHEME_RES,S_OK,FALSE},
{URLZONE_INVALID,E_NOTIMPL,FALSE}
}
} }
}; };
...@@ -3913,7 +4017,14 @@ static const invalid_uri invalid_uri_tests[] = { ...@@ -3913,7 +4017,14 @@ static const invalid_uri invalid_uri_tests[] = {
{"file://c:\\test\"test",Uri_CREATE_FILE_USE_DOS_PATH,FALSE}, {"file://c:\\test\"test",Uri_CREATE_FILE_USE_DOS_PATH,FALSE},
{"file:c:\\test<test",Uri_CREATE_FILE_USE_DOS_PATH,FALSE}, {"file:c:\\test<test",Uri_CREATE_FILE_USE_DOS_PATH,FALSE},
{"file:c:\\test>test",Uri_CREATE_FILE_USE_DOS_PATH,FALSE}, {"file:c:\\test>test",Uri_CREATE_FILE_USE_DOS_PATH,FALSE},
{"file:c:\\test\"test",Uri_CREATE_FILE_USE_DOS_PATH,FALSE} {"file:c:\\test\"test",Uri_CREATE_FILE_USE_DOS_PATH,FALSE},
/* res URIs aren't allowed to have forbidden dos path characters in the
* hostname.
*/
{"res://c:\\te<st\\test/test",0,FALSE},
{"res://c:\\te>st\\test/test",0,FALSE},
{"res://c:\\te\"st\\test/test",0,FALSE},
{"res://c:\\test/te%xxst",0,FALSE}
}; };
typedef struct _uri_equality { typedef struct _uri_equality {
......
...@@ -1552,8 +1552,11 @@ static BOOL parse_ipv4address(const WCHAR **ptr, parse_data *data, DWORD flags) ...@@ -1552,8 +1552,11 @@ static BOOL parse_ipv4address(const WCHAR **ptr, parse_data *data, DWORD flags)
static BOOL parse_reg_name(const WCHAR **ptr, parse_data *data, DWORD flags, DWORD extras) { static BOOL parse_reg_name(const WCHAR **ptr, parse_data *data, DWORD flags, DWORD extras) {
const BOOL has_start_bracket = **ptr == '['; const BOOL has_start_bracket = **ptr == '[';
const BOOL known_scheme = data->scheme_type != URL_SCHEME_UNKNOWN; const BOOL known_scheme = data->scheme_type != URL_SCHEME_UNKNOWN;
const BOOL is_res = data->scheme_type == URL_SCHEME_RES;
BOOL inside_brackets = has_start_bracket; BOOL inside_brackets = has_start_bracket;
BOOL ignore_col = extras & IGNORE_PORT_DELIMITER;
/* res URIs don't have ports. */
BOOL ignore_col = (extras & IGNORE_PORT_DELIMITER) || is_res;
/* We have to be careful with file schemes. */ /* We have to be careful with file schemes. */
if(data->scheme_type == URL_SCHEME_FILE) { if(data->scheme_type == URL_SCHEME_FILE) {
...@@ -1575,7 +1578,11 @@ static BOOL parse_reg_name(const WCHAR **ptr, parse_data *data, DWORD flags, DWO ...@@ -1575,7 +1578,11 @@ static BOOL parse_reg_name(const WCHAR **ptr, parse_data *data, DWORD flags, DWO
data->host = *ptr; data->host = *ptr;
while(!is_auth_delim(**ptr, known_scheme)) { /* For res URIs, everything before the first '/' is
* considered the host.
*/
while((!is_res && !is_auth_delim(**ptr, known_scheme)) ||
(is_res && **ptr && **ptr != '/')) {
if(**ptr == ':' && !ignore_col) { if(**ptr == ':' && !ignore_col) {
/* We can ignore ':' if were inside brackets.*/ /* We can ignore ':' if were inside brackets.*/
if(!inside_brackets) { if(!inside_brackets) {
...@@ -1599,7 +1606,7 @@ static BOOL parse_reg_name(const WCHAR **ptr, parse_data *data, DWORD flags, DWO ...@@ -1599,7 +1606,7 @@ static BOOL parse_reg_name(const WCHAR **ptr, parse_data *data, DWORD flags, DWO
break; break;
} }
} }
} else if(**ptr == '%' && known_scheme) { } else if(**ptr == '%' && (known_scheme && !is_res)) {
/* Has to be a legit % encoded value. */ /* Has to be a legit % encoded value. */
if(!check_pct_encoded(ptr)) { if(!check_pct_encoded(ptr)) {
*ptr = data->host; *ptr = data->host;
...@@ -1607,6 +1614,10 @@ static BOOL parse_reg_name(const WCHAR **ptr, parse_data *data, DWORD flags, DWO ...@@ -1607,6 +1614,10 @@ static BOOL parse_reg_name(const WCHAR **ptr, parse_data *data, DWORD flags, DWO
return FALSE; return FALSE;
} else } else
continue; continue;
} else if(is_res && is_forbidden_dos_path_char(**ptr)) {
*ptr = data->host;
data->host = NULL;
return FALSE;
} else if(**ptr == ']') } else if(**ptr == ']')
inside_brackets = FALSE; inside_brackets = FALSE;
else if(**ptr == '[') else if(**ptr == '[')
...@@ -1631,7 +1642,7 @@ static BOOL parse_reg_name(const WCHAR **ptr, parse_data *data, DWORD flags, DWO ...@@ -1631,7 +1642,7 @@ static BOOL parse_reg_name(const WCHAR **ptr, parse_data *data, DWORD flags, DWO
data->host_len = *ptr - data->host; data->host_len = *ptr - data->host;
/* If the host is empty, then it's an unknown host type. */ /* If the host is empty, then it's an unknown host type. */
if(data->host_len == 0) if(data->host_len == 0 || is_res)
data->host_type = Uri_HOST_UNKNOWN; data->host_type = Uri_HOST_UNKNOWN;
else else
data->host_type = Uri_HOST_DNS; data->host_type = Uri_HOST_DNS;
...@@ -2913,6 +2924,7 @@ static BOOL canonicalize_path_hierarchical(const parse_data *data, Uri *uri, ...@@ -2913,6 +2924,7 @@ static BOOL canonicalize_path_hierarchical(const parse_data *data, Uri *uri,
const WCHAR *ptr; const WCHAR *ptr;
const BOOL known_scheme = data->scheme_type != URL_SCHEME_UNKNOWN; const BOOL known_scheme = data->scheme_type != URL_SCHEME_UNKNOWN;
const BOOL is_file = data->scheme_type == URL_SCHEME_FILE; const BOOL is_file = data->scheme_type == URL_SCHEME_FILE;
const BOOL is_res = data->scheme_type == URL_SCHEME_RES;
BOOL escape_pct = FALSE; BOOL escape_pct = FALSE;
...@@ -2961,7 +2973,7 @@ static BOOL canonicalize_path_hierarchical(const parse_data *data, Uri *uri, ...@@ -2961,7 +2973,7 @@ static BOOL canonicalize_path_hierarchical(const parse_data *data, Uri *uri,
} }
for(; ptr < data->path+data->path_len; ++ptr) { for(; ptr < data->path+data->path_len; ++ptr) {
if(*ptr == '%') { if(*ptr == '%' && !is_res) {
const WCHAR *tmp = ptr; const WCHAR *tmp = ptr;
WCHAR val; WCHAR val;
...@@ -3004,7 +3016,7 @@ static BOOL canonicalize_path_hierarchical(const parse_data *data, Uri *uri, ...@@ -3004,7 +3016,7 @@ static BOOL canonicalize_path_hierarchical(const parse_data *data, Uri *uri,
uri->canon_uri[uri->canon_len] = '/'; uri->canon_uri[uri->canon_len] = '/';
++uri->canon_len; ++uri->canon_len;
} }
} else if(known_scheme && !is_unreserved(*ptr) && !is_reserved(*ptr) && } else if(known_scheme && !is_res && !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)) {
/* Don't escape the character. */ /* Don't escape the character. */
......
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