Commit 26a36907 authored by Zebediah Figura's avatar Zebediah Figura Committed by Alexandre Julliard

kernelbase: Do not parse the hostname of internet URLs if they are missing a double slash.

parent a110b2e6
...@@ -4204,7 +4204,11 @@ static void parse_url( const WCHAR *url, struct parsed_url *pl ) ...@@ -4204,7 +4204,11 @@ static void parse_url( const WCHAR *url, struct parsed_url *pl )
work++; work++;
pl->scheme_number = get_scheme_code(pl->scheme, pl->scheme_len); pl->scheme_number = get_scheme_code(pl->scheme, pl->scheme_len);
if (!is_slash( work[0] ) || !is_slash( work[1] )) if (!is_slash( work[0] ) || !is_slash( work[1] ))
{
if (pl->scheme_number != URL_SCHEME_FILE)
pl->scheme_number = URL_SCHEME_UNKNOWN;
return; return;
}
work += 2; work += 2;
if (pl->scheme_number != URL_SCHEME_FILE) if (pl->scheme_number != URL_SCHEME_FILE)
......
...@@ -596,7 +596,6 @@ static void test_UrlGetPart(void) ...@@ -596,7 +596,6 @@ static void test_UrlGetPart(void)
DWORD flags; DWORD flags;
HRESULT hr; HRESULT hr;
const char *expect; const char *expect;
BOOL todo_hr;
} }
tests[] = tests[] =
{ {
...@@ -657,8 +656,8 @@ static void test_UrlGetPart(void) ...@@ -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_USERNAME, 0, S_OK, "user"},
{"http://user@host@q", URL_PART_HOSTNAME, 0, S_OK, "host@q"}, {"http://user@host@q", URL_PART_HOSTNAME, 0, S_OK, "host@q"},
{"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, .todo_hr = TRUE}, {"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"},
{"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) ...@@ -780,13 +779,10 @@ static void test_UrlGetPart(void)
size = 1; size = 1;
strcpy(buffer, "x"); strcpy(buffer, "x");
hr = UrlGetPartA(url, buffer, &size, part, flags); hr = UrlGetPartA(url, buffer, &size, part, flags);
todo_wine_if (tests[i].todo_hr)
{
if (tests[i].hr == S_OK) if (tests[i].hr == S_OK)
ok(hr == E_POINTER, "Got hr %#lx.\n", hr); ok(hr == E_POINTER, "Got hr %#lx.\n", hr);
else else
ok(hr == tests[i].hr, "Got hr %#lx.\n", hr); ok(hr == tests[i].hr, "Got hr %#lx.\n", hr);
}
if (hr == S_FALSE) if (hr == S_FALSE)
{ {
...@@ -796,34 +792,21 @@ static void test_UrlGetPart(void) ...@@ -796,34 +792,21 @@ static void test_UrlGetPart(void)
else else
{ {
if (hr == E_POINTER) 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 else
{
ok(size == 1, "Got size %lu.\n", size); ok(size == 1, "Got size %lu.\n", size);
}
ok(!strcmp(buffer, "x"), "Got result %s.\n", debugstr_a(buffer)); ok(!strcmp(buffer, "x"), "Got result %s.\n", debugstr_a(buffer));
} }
size = sizeof(buffer); size = sizeof(buffer);
strcpy(buffer, "x"); strcpy(buffer, "x");
hr = UrlGetPartA(url, buffer, &size, part, flags); 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)) if (SUCCEEDED(hr))
{ {
ok(size == strlen(buffer), "Got size %lu.\n", size); 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 else
{ {
ok(size == sizeof(buffer), "Got size %lu.\n", size); ok(size == sizeof(buffer), "Got size %lu.\n", size);
...@@ -835,13 +818,10 @@ static void test_UrlGetPart(void) ...@@ -835,13 +818,10 @@ static void test_UrlGetPart(void)
size = 1; size = 1;
wcscpy(bufferW, L"x"); wcscpy(bufferW, L"x");
hr = UrlGetPartW(urlW, bufferW, &size, part, flags); hr = UrlGetPartW(urlW, bufferW, &size, part, flags);
todo_wine_if (tests[i].todo_hr)
{
if (tests[i].hr == S_OK) if (tests[i].hr == S_OK)
ok(hr == E_POINTER, "Got hr %#lx.\n", hr); ok(hr == E_POINTER, "Got hr %#lx.\n", hr);
else else
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)) if (SUCCEEDED(hr))
{ {
...@@ -851,24 +831,15 @@ static void test_UrlGetPart(void) ...@@ -851,24 +831,15 @@ static void test_UrlGetPart(void)
else else
{ {
if (hr == E_POINTER) 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 else
{
ok(size == 1, "Got size %lu.\n", size); ok(size == 1, "Got size %lu.\n", size);
}
ok(!wcscmp(bufferW, L"x"), "Got result %s.\n", debugstr_w(bufferW)); ok(!wcscmp(bufferW, L"x"), "Got result %s.\n", debugstr_w(bufferW));
} }
size = ARRAY_SIZE(bufferW); size = ARRAY_SIZE(bufferW);
wcscpy(bufferW, L"x"); wcscpy(bufferW, L"x");
hr = UrlGetPartW(urlW, bufferW, &size, part, flags); 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)) if (SUCCEEDED(hr))
{ {
......
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