[PATCH 4/4] kernelbase: Do not parse the hostname of internet URLs if they are missing a double slash.
Zebediah Figura
zfigura at codeweavers.com
Tue Mar 22 23:28:03 CDT 2022
Signed-off-by: Zebediah Figura <zfigura at codeweavers.com>
---
dlls/kernelbase/path.c | 4 +++
dlls/shlwapi/tests/url.c | 59 ++++++++++------------------------------
2 files changed, 19 insertions(+), 44 deletions(-)
diff --git a/dlls/kernelbase/path.c b/dlls/kernelbase/path.c
index fbe4728efda..7eda9bd483c 100644
--- a/dlls/kernelbase/path.c
+++ b/dlls/kernelbase/path.c
@@ -4204,7 +4204,11 @@ static void parse_url( const WCHAR *url, struct parsed_url *pl )
work++;
pl->scheme_number = get_scheme_code(pl->scheme, pl->scheme_len);
if (!is_slash( work[0] ) || !is_slash( work[1] ))
+ {
+ if (pl->scheme_number != URL_SCHEME_FILE)
+ pl->scheme_number = URL_SCHEME_UNKNOWN;
return;
+ }
work += 2;
if (pl->scheme_number != URL_SCHEME_FILE)
diff --git a/dlls/shlwapi/tests/url.c b/dlls/shlwapi/tests/url.c
index 7cf7097a9ba..6957e244213 100644
--- a/dlls/shlwapi/tests/url.c
+++ b/dlls/shlwapi/tests/url.c
@@ -596,7 +596,6 @@ static void test_UrlGetPart(void)
DWORD flags;
HRESULT hr;
const char *expect;
- BOOL todo_hr;
}
tests[] =
{
@@ -657,8 +656,8 @@ static void test_UrlGetPart(void)
{"http://user@host@q", URL_PART_USERNAME, 0, S_OK, "user"},
{"http://user@host@q", URL_PART_HOSTNAME, 0, S_OK, "host at q"},
- {"http:localhost/index.html", URL_PART_HOSTNAME, 0, E_FAIL, .todo_hr = TRUE},
- {"http:/localhost/index.html", URL_PART_HOSTNAME, 0, E_FAIL, .todo_hr = TRUE},
+ {"http:localhost/index.html", URL_PART_HOSTNAME, 0, E_FAIL},
+ {"http:/localhost/index.html", URL_PART_HOSTNAME, 0, E_FAIL},
{"http://localhost\\index.html", URL_PART_HOSTNAME, 0, S_OK, "localhost"},
{"http:/\\localhost/index.html", URL_PART_HOSTNAME, 0, S_OK, "localhost"},
@@ -780,13 +779,10 @@ static void test_UrlGetPart(void)
size = 1;
strcpy(buffer, "x");
hr = UrlGetPartA(url, buffer, &size, part, flags);
- todo_wine_if (tests[i].todo_hr)
- {
- if (tests[i].hr == S_OK)
- ok(hr == E_POINTER, "Got hr %#lx.\n", hr);
- else
- ok(hr == tests[i].hr, "Got hr %#lx.\n", hr);
- }
+ if (tests[i].hr == S_OK)
+ ok(hr == E_POINTER, "Got hr %#lx.\n", hr);
+ else
+ ok(hr == tests[i].hr, "Got hr %#lx.\n", hr);
if (hr == S_FALSE)
{
@@ -796,33 +792,20 @@ static void test_UrlGetPart(void)
else
{
if (hr == E_POINTER)
- {
- if (expect)
- {
- todo_wine_if (tests[i].todo_hr)
- ok(size == strlen(expect) + 1, "Got size %lu.\n", size);
- }
- }
+ ok(size == strlen(expect) + 1, "Got size %lu.\n", size);
else
- {
ok(size == 1, "Got size %lu.\n", size);
- }
ok(!strcmp(buffer, "x"), "Got result %s.\n", debugstr_a(buffer));
}
size = sizeof(buffer);
strcpy(buffer, "x");
hr = UrlGetPartA(url, buffer, &size, part, flags);
- todo_wine_if (tests[i].todo_hr)
- ok(hr == tests[i].hr, "Got hr %#lx.\n", hr);
+ ok(hr == tests[i].hr, "Got hr %#lx.\n", hr);
if (SUCCEEDED(hr))
{
ok(size == strlen(buffer), "Got size %lu.\n", size);
- if (expect)
- {
- todo_wine_if (tests[i].todo_hr)
- ok(!strcmp(buffer, expect), "Got result %s.\n", debugstr_a(buffer));
- }
+ ok(!strcmp(buffer, expect), "Got result %s.\n", debugstr_a(buffer));
}
else
{
@@ -835,13 +818,10 @@ static void test_UrlGetPart(void)
size = 1;
wcscpy(bufferW, L"x");
hr = UrlGetPartW(urlW, bufferW, &size, part, flags);
- todo_wine_if (tests[i].todo_hr)
- {
- if (tests[i].hr == S_OK)
- ok(hr == E_POINTER, "Got hr %#lx.\n", hr);
- else
- ok(hr == (tests[i].hr == S_FALSE ? S_OK : tests[i].hr), "Got hr %#lx.\n", hr);
- }
+ if (tests[i].hr == S_OK)
+ ok(hr == E_POINTER, "Got hr %#lx.\n", hr);
+ else
+ ok(hr == (tests[i].hr == S_FALSE ? S_OK : tests[i].hr), "Got hr %#lx.\n", hr);
if (SUCCEEDED(hr))
{
@@ -851,25 +831,16 @@ static void test_UrlGetPart(void)
else
{
if (hr == E_POINTER)
- {
- if (expect)
- {
- todo_wine_if (tests[i].todo_hr)
- ok(size == strlen(expect) + 1, "Got size %lu.\n", size);
- }
- }
+ ok(size == strlen(expect) + 1, "Got size %lu.\n", size);
else
- {
ok(size == 1, "Got size %lu.\n", size);
- }
ok(!wcscmp(bufferW, L"x"), "Got result %s.\n", debugstr_w(bufferW));
}
size = ARRAY_SIZE(bufferW);
wcscpy(bufferW, L"x");
hr = UrlGetPartW(urlW, bufferW, &size, part, flags);
- todo_wine_if (tests[i].todo_hr)
- ok(hr == (tests[i].hr == S_FALSE ? S_OK : tests[i].hr), "Got hr %#lx.\n", hr);
+ ok(hr == (tests[i].hr == S_FALSE ? S_OK : tests[i].hr), "Got hr %#lx.\n", hr);
if (SUCCEEDED(hr))
{
ok(size == wcslen(bufferW), "Got size %lu.\n", size);
--
2.34.1
More information about the wine-devel
mailing list