kernelbase: Prepend the scheme even if the requested URL part is empty.

Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Zebediah Figura 2022-02-16 20:31:43 -06:00 committed by Alexandre Julliard
parent 91ae5ffe08
commit 439600d5ce
2 changed files with 7 additions and 42 deletions

View File

@ -4277,12 +4277,6 @@ HRESULT WINAPI UrlGetPartW(const WCHAR *url, WCHAR *out, DWORD *out_len, DWORD p
{
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;
@ -4290,30 +4284,19 @@ HRESULT WINAPI UrlGetPartW(const WCHAR *url, WCHAR *out, DWORD *out_len, DWORD p
case URL_PART_HOSTNAME:
if (scheme == URL_SCHEME_FILE && (!pl.hostname_len || (pl.hostname_len == 1 && *(pl.hostname + 1) == ':')))
{
*out = '\0';
*out_len = 0;
return S_FALSE;
addr = NULL;
size = 0;
}
if (!pl.hostname_len)
else
{
*out = '\0';
*out_len = 0;
return S_FALSE;
addr = pl.hostname;
size = pl.hostname_len;
}
addr = pl.hostname;
size = pl.hostname_len;
break;
case URL_PART_USERNAME:
if (!pl.username)
return E_INVALIDARG;
if (!pl.username_len)
{
*out = '\0';
*out_len = 0;
return S_FALSE;
}
addr = pl.username;
size = pl.username_len;
break;
@ -4321,12 +4304,6 @@ HRESULT WINAPI UrlGetPartW(const WCHAR *url, WCHAR *out, DWORD *out_len, DWORD p
case URL_PART_PASSWORD:
if (!pl.password)
return E_INVALIDARG;
if (!pl.password_len)
{
*out = '\0';
*out_len = 0;
return S_FALSE;
}
addr = pl.password;
size = pl.password_len;
break;
@ -4334,24 +4311,12 @@ HRESULT WINAPI UrlGetPartW(const WCHAR *url, WCHAR *out, DWORD *out_len, DWORD p
case URL_PART_PORT:
if (!pl.port)
return E_INVALIDARG;
if (!pl.port_len)
{
*out = '\0';
*out_len = 0;
return S_FALSE;
}
addr = pl.port;
size = pl.port_len;
break;
case URL_PART_QUERY:
flags &= ~URL_PARTFLAG_KEEPSCHEME;
if (!pl.query_len)
{
*out = '\0';
*out_len = 0;
return S_FALSE;
}
addr = pl.query;
size = pl.query_len;
break;
@ -4401,7 +4366,7 @@ HRESULT WINAPI UrlGetPartW(const WCHAR *url, WCHAR *out, DWORD *out_len, DWORD p
}
TRACE("len=%ld %s\n", *out_len, wine_dbgstr_w(out));
return S_OK;
return *out_len ? S_OK : S_FALSE;
}
BOOL WINAPI UrlIsA(const char *url, URLIS Urlis)

View File

@ -681,7 +681,7 @@ static void test_UrlGetPart(void)
{"http://host: !\"$%&'()*+,-.;<=>[]^_`{|~}\x01\x7f\xff", URL_PART_PORT, 0, S_OK, " !\"$%&'()*+,-.;<=>[]^_`{|~}\x01\x7f\xff"},
{"http:///index.html", URL_PART_HOSTNAME, 0, S_FALSE, ""},
{"http:///index.html", URL_PART_HOSTNAME, URL_PARTFLAG_KEEPSCHEME, S_OK, "http:", .todo_hr = TRUE},
{"http:///index.html", URL_PART_HOSTNAME, URL_PARTFLAG_KEEPSCHEME, S_OK, "http:"},
{"file://h o s t/c:/windows/file", URL_PART_HOSTNAME, 0, S_OK, "h o s t"},
{"file://h o s t/c:/windows/file", URL_PART_HOSTNAME, URL_PARTFLAG_KEEPSCHEME, S_OK, "h o s t"},
{"file://foo:bar@localhost:21/file?query=x", URL_PART_USERNAME, 0, E_FAIL, .todo_hr = TRUE},