Commit ef64aea7 authored by Zebediah Figura's avatar Zebediah Figura Committed by Alexandre Julliard

kernelbase: Also return E_FAIL when trying to parse username, password, or port…

kernelbase: Also return E_FAIL when trying to parse username, password, or port for non-Internet URLs. Signed-off-by: 's avatarZebediah Figura <zfigura@codeweavers.com> Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent 824fcbae
......@@ -4329,21 +4329,6 @@ HRESULT WINAPI UrlGetPartW(const WCHAR *url, WCHAR *out, DWORD *out_len, DWORD p
hr = parse_url(url, &pl);
switch (part)
{
case URL_PART_SCHEME:
flags &= ~URL_PARTFLAG_KEEPSCHEME;
if (!pl.scheme_len)
{
*out = '\0';
*out_len = 0;
return S_FALSE;
}
addr = pl.scheme;
size = pl.scheme_len;
break;
case URL_PART_HOSTNAME:
switch (scheme)
{
case URL_SCHEME_FILE:
......@@ -4356,10 +4341,27 @@ HRESULT WINAPI UrlGetPartW(const WCHAR *url, WCHAR *out, DWORD *out_len, DWORD p
case URL_SCHEME_NNTP:
case URL_SCHEME_SNEWS:
break;
default:
if (part != URL_PART_SCHEME && part != URL_PART_QUERY)
return E_FAIL;
}
switch (part)
{
case URL_PART_SCHEME:
flags &= ~URL_PARTFLAG_KEEPSCHEME;
if (!pl.scheme_len)
{
*out = '\0';
*out_len = 0;
return S_FALSE;
}
addr = pl.scheme;
size = pl.scheme_len;
break;
case URL_PART_HOSTNAME:
if (scheme == URL_SCHEME_FILE && (!pl.hostname_len || (pl.hostname_len == 1 && *(pl.hostname + 1) == ':')))
{
*out = '\0';
......
......@@ -601,10 +601,10 @@ static void test_UrlGetPart(void)
tests[] =
{
{"hi", URL_PART_SCHEME, 0, S_FALSE, ""},
{"hi", URL_PART_USERNAME, 0, E_FAIL, .todo_hr = TRUE},
{"hi", URL_PART_PASSWORD, 0, E_FAIL, .todo_hr = TRUE},
{"hi", URL_PART_USERNAME, 0, E_FAIL},
{"hi", URL_PART_PASSWORD, 0, E_FAIL},
{"hi", URL_PART_HOSTNAME, 0, E_FAIL},
{"hi", URL_PART_PORT, 0, E_FAIL, .todo_hr = TRUE},
{"hi", URL_PART_PORT, 0, E_FAIL},
{"hi", URL_PART_QUERY, 0, S_FALSE, ""},
{"http://foo:bar@localhost:21/internal.php?query=x&return=y", URL_PART_SCHEME, 0, S_OK, "http"},
......
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