Commit 93d79ee1 authored by Thomas Mullaly's avatar Thomas Mullaly Committed by Alexandre Julliard

urlmon: Implemented a path parser for opaque URIs.

parent 0ecec6d7
......@@ -2245,6 +2245,34 @@ static const uri_properties uri_tests[] = {
{URL_SCHEME_UNKNOWN,S_OK,FALSE},
{URLZONE_INVALID,E_NOTIMPL,FALSE}
}
},
{ "urn:excepts:bad:%XY:encoded", 0, S_OK, FALSE,
Uri_HAS_ABSOLUTE_URI|Uri_HAS_DISPLAY_URI|Uri_HAS_PATH|Uri_HAS_PATH_AND_QUERY|
Uri_HAS_RAW_URI|Uri_HAS_SCHEME_NAME|Uri_HAS_HOST_TYPE|Uri_HAS_SCHEME,
TRUE,
{
{"urn:excepts:bad:%XY:encoded",S_OK,TRUE},
{"",S_FALSE,FALSE},
{"urn:excepts:bad:%XY:encoded",S_OK,TRUE},
{"",S_FALSE,FALSE},
{"",S_FALSE,TRUE},
{"",S_FALSE,TRUE},
{"",S_FALSE,FALSE},
{"",S_FALSE,FALSE},
{"excepts:bad:%XY:encoded",S_OK,TRUE},
{"excepts:bad:%XY:encoded",S_OK,TRUE},
{"",S_FALSE,TRUE},
{"urn:excepts:bad:%XY:encoded",S_OK,FALSE},
{"urn",S_OK,FALSE},
{"",S_FALSE,FALSE},
{"",S_FALSE,FALSE}
},
{
{Uri_HOST_UNKNOWN,S_OK,FALSE},
{0,S_FALSE,FALSE},
{URL_SCHEME_UNKNOWN,S_OK,FALSE},
{URLZONE_INVALID,E_NOTIMPL,FALSE}
}
}
};
......@@ -2294,7 +2322,10 @@ static const invalid_uri invalid_uri_tests[] = {
/* Invalid port with IPv6 address. */
{"http://[::ffff]:32xy",0,FALSE},
/* Not allowed to have backslashes with NO_CANONICALIZE. */
{"gopher://www.google.com\\test",Uri_CREATE_NO_CANONICALIZE,FALSE}
{"gopher://www.google.com\\test",Uri_CREATE_NO_CANONICALIZE,FALSE},
/* Not allowed to have invalid % encoded data in opaque URI path. */
{"news:test%XX",0,FALSE},
{"mailto:wine@winehq%G8.com",0,FALSE}
};
typedef struct _uri_equality {
......
......@@ -1553,6 +1553,37 @@ static BOOL parse_path_hierarchical(const WCHAR **ptr, parse_data *data, DWORD f
return TRUE;
}
/* Parses the path of a opaque URI (much less strict then the parser
* for a hierarchical URI).
*
* NOTE:
* Windows allows invalid % encoded data to appear in opaque URI paths
* for unknown scheme types.
*/
static BOOL parse_path_opaque(const WCHAR **ptr, parse_data *data, DWORD flags) {
const BOOL known_scheme = data->scheme_type != URL_SCHEME_UNKNOWN;
data->path = *ptr;
while(!is_path_delim(**ptr)) {
if(**ptr == '%' && known_scheme) {
if(!check_pct_encoded(ptr)) {
*ptr = data->path;
data->path = NULL;
return FALSE;
} else
continue;
}
++(*ptr);
}
data->path_len = *ptr - data->path;
TRACE("(%p %p %x): Parsed opaque URI path %s len=%d\n", ptr, data, flags,
debugstr_wn(data->path, data->path_len), data->path_len);
return TRUE;
}
/* Determines how the URI should be parsed after the scheme information.
*
* If the scheme is followed, by "//" then, it is treated as an hierarchical URI
......@@ -1615,7 +1646,9 @@ static BOOL parse_hierpart(const WCHAR **ptr, parse_data *data, DWORD flags) {
TRACE("(%p %p %x): Treating URI as an opaque URI.\n", ptr, data, flags);
data->is_opaque = TRUE;
/* TODO: Handle opaque URI's, parse path. */
if(!parse_path_opaque(ptr, data, flags))
return FALSE;
return TRUE;
}
......
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