From 2784e1acedf31506fc402dd71daf0b455718d2ba Mon Sep 17 00:00:00 2001 From: Thomas Mullaly Date: Sat, 24 Sep 2011 17:56:22 -0400 Subject: [PATCH] urlmon: Improved IUri support for wildcard URLs. --- dlls/urlmon/tests/uri.c | 25 +++++++++++++++++++++++++ dlls/urlmon/uri.c | 18 ++++++++++++++---- 2 files changed, 39 insertions(+), 4 deletions(-) diff --git a/dlls/urlmon/tests/uri.c b/dlls/urlmon/tests/uri.c index d08dd5b4be6..348387870ff 100644 --- a/dlls/urlmon/tests/uri.c +++ b/dlls/urlmon/tests/uri.c @@ -4291,6 +4291,31 @@ static const uri_properties uri_tests[] = { {URL_SCHEME_JAVASCRIPT,S_OK}, {URLZONE_INVALID,E_NOTIMPL} } + }, + { "*://google.com", 0, S_OK, FALSE, + { + {"*:google.com/",S_OK,FALSE}, + {"google.com",S_OK}, + {"*:google.com/",S_OK,FALSE}, + {"google.com",S_OK,FALSE}, + {"",S_FALSE,FALSE}, + {"",S_FALSE,FALSE}, + {"google.com",S_OK,FALSE}, + {"",S_FALSE,FALSE}, + {"/",S_OK,FALSE}, + {"/",S_OK,FALSE}, + {"",S_FALSE,FALSE}, + {"*://google.com",S_OK,FALSE}, + {"*",S_OK,FALSE}, + {"",S_FALSE,FALSE}, + {"",S_FALSE,FALSE} + }, + { + {Uri_HOST_DNS,S_OK,FALSE}, + {0,S_FALSE,FALSE}, + {URL_SCHEME_WILDCARD,S_OK,FALSE}, + {URLZONE_INVALID,E_NOTIMPL,FALSE} + } } }; diff --git a/dlls/urlmon/uri.c b/dlls/urlmon/uri.c index 5dfa8b83b64..2b0b9ad68d6 100644 --- a/dlls/urlmon/uri.c +++ b/dlls/urlmon/uri.c @@ -155,6 +155,7 @@ typedef struct { BOOL has_implicit_scheme; BOOL has_implicit_ip; UINT implicit_ipv4; + BOOL must_have_path; const WCHAR *scheme; DWORD scheme_len; @@ -1938,10 +1939,7 @@ static BOOL parse_path_hierarchical(const WCHAR **ptr, parse_data *data, DWORD f const BOOL is_file = data->scheme_type == URL_SCHEME_FILE; if(is_path_delim(**ptr)) { - if(data->scheme_type == URL_SCHEME_WILDCARD) { - /* Wildcard schemes don't get a '/' attached if their path is - * empty. - */ + if(data->scheme_type == URL_SCHEME_WILDCARD && !data->must_have_path) { data->path = NULL; data->path_len = 0; } else if(!(flags & Uri_CREATE_NO_CANONICALIZE)) { @@ -2068,6 +2066,8 @@ static BOOL parse_path_opaque(const WCHAR **ptr, parse_data *data, DWORD flags) static BOOL parse_hierpart(const WCHAR **ptr, parse_data *data, DWORD flags) { const WCHAR *start = *ptr; + data->must_have_path = FALSE; + /* For javascript: URIs, simply set everything as a path */ if(data->scheme_type == URL_SCHEME_JAVASCRIPT) { data->path = *ptr; @@ -2087,6 +2087,13 @@ static BOOL parse_hierpart(const WCHAR **ptr, parse_data *data, DWORD flags) { TRACE("(%p %p %x): Treating URI as an hierarchical URI.\n", ptr, data, flags); data->is_opaque = FALSE; + if(data->scheme_type == URL_SCHEME_WILDCARD && !data->has_implicit_scheme) { + if(**ptr == '/' && *(*ptr+1) == '/') { + data->must_have_path = TRUE; + *ptr += 2; + } + } + /* TODO: Handle hierarchical URI's, parse authority then parse the path. */ if(!parse_authority(ptr, data, flags)) return FALSE; @@ -3184,6 +3191,9 @@ static BOOL canonicalize_hierpart(const parse_data *data, Uri *uri, DWORD flags, */ if((data->is_relative && (data->host || data->has_port)) || (!data->is_relative && data->scheme_type != URL_SCHEME_WILDCARD)) { + if(data->scheme_type == URL_SCHEME_WILDCARD) + FIXME("Here\n"); + if(!computeOnly) { INT pos = uri->canon_len;