Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- dlls/kernelbase/path.c | 4 ++-- dlls/shlwapi/tests/url.c | 8 +++----- 2 files changed, 5 insertions(+), 7 deletions(-)
diff --git a/dlls/kernelbase/path.c b/dlls/kernelbase/path.c index 7cfff358fdb..15280a7ea4b 100644 --- a/dlls/kernelbase/path.c +++ b/dlls/kernelbase/path.c @@ -4148,10 +4148,10 @@ HRESULT WINAPI UrlGetPartA(const char *url, char *out, DWORD *out_len, DWORD par return hr; }
- len2 = WideCharToMultiByte(CP_ACP, 0, outW, len, NULL, 0, NULL, NULL); + len2 = WideCharToMultiByte(CP_ACP, 0, outW, len + 1, NULL, 0, NULL, NULL); if (len2 > *out_len) { - *out_len = len2 + 1; + *out_len = len2; heap_free(inW); return E_POINTER; } diff --git a/dlls/shlwapi/tests/url.c b/dlls/shlwapi/tests/url.c index 212ee039a0b..b4b66aec2f1 100644 --- a/dlls/shlwapi/tests/url.c +++ b/dlls/shlwapi/tests/url.c @@ -782,7 +782,7 @@ static void test_UrlGetPart(void) size = 1; strcpy(buffer, "x"); hr = UrlGetPartA(url, buffer, &size, part, flags); - todo_wine_if (tests[i].todo_hr || !strcmp(url, "http://host?a:b@c:d")) + todo_wine_if (tests[i].todo_hr) { if (tests[i].hr == S_OK) ok(hr == E_POINTER, "Got hr %#x.\n", hr); @@ -807,11 +807,9 @@ static void test_UrlGetPart(void) } else { - todo_wine_if (hr == S_OK) - ok(size == 1, "Got size %u.\n", size); + ok(size == 1, "Got size %u.\n", size); } - todo_wine_if (hr == S_OK) - 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);
Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- dlls/kernelbase/path.c | 2 ++ dlls/shlwapi/tests/url.c | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/dlls/kernelbase/path.c b/dlls/kernelbase/path.c index 15280a7ea4b..e716351b0bc 100644 --- a/dlls/kernelbase/path.c +++ b/dlls/kernelbase/path.c @@ -4334,6 +4334,7 @@ HRESULT WINAPI UrlGetPartW(const WCHAR *url, WCHAR *out, DWORD *out_len, DWORD p switch (part) { case URL_PART_SCHEME: + flags &= ~URL_PARTFLAG_KEEPSCHEME; if (!pl.scheme_len) { *out_len = 0; @@ -4404,6 +4405,7 @@ HRESULT WINAPI UrlGetPartW(const WCHAR *url, WCHAR *out, DWORD *out_len, DWORD p break;
case URL_PART_QUERY: + flags &= ~URL_PARTFLAG_KEEPSCHEME; if (!pl.query_len) { *out_len = 0; diff --git a/dlls/shlwapi/tests/url.c b/dlls/shlwapi/tests/url.c index b4b66aec2f1..b2b20b94b1b 100644 --- a/dlls/shlwapi/tests/url.c +++ b/dlls/shlwapi/tests/url.c @@ -614,7 +614,7 @@ static void test_UrlGetPart(void) {"http://foo:bar@localhost:21/internal.php?query=x&return=y", URL_PART_PORT, 0, S_OK, "21"}, {"http://foo:bar@localhost:21/internal.php?query=x&return=y", URL_PART_QUERY, 0, S_OK, "query=x&return=y", .todo_result = TRUE}, {"http://foo:bar@localhost:21/internal.php#anchor", URL_PART_QUERY, 0, S_FALSE, ""}, - {"http://foo:bar@localhost:21/internal.php?query=x&return=y", URL_PART_SCHEME, URL_PARTFLAG_KEEPSCHEME, S_OK, "http", .todo_result = TRUE}, + {"http://foo:bar@localhost:21/internal.php?query=x&return=y", URL_PART_SCHEME, URL_PARTFLAG_KEEPSCHEME, S_OK, "http"}, {"http://foo:bar@localhost:21/internal.php?query=x&return=y", URL_PART_USERNAME, URL_PARTFLAG_KEEPSCHEME, S_OK, "http:foo"}, {"http://foo:bar@localhost:21/internal.php?query=x&return=y", URL_PART_PASSWORD, URL_PARTFLAG_KEEPSCHEME, S_OK, "http:bar"}, {"http://foo:bar@localhost:21/internal.php?query=x&return=y", URL_PART_HOSTNAME, URL_PARTFLAG_KEEPSCHEME, S_OK, "http:localhost"},
Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- dlls/kernelbase/path.c | 2 +- dlls/shlwapi/tests/url.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/dlls/kernelbase/path.c b/dlls/kernelbase/path.c index e716351b0bc..c3d3e734cf7 100644 --- a/dlls/kernelbase/path.c +++ b/dlls/kernelbase/path.c @@ -4420,7 +4420,7 @@ HRESULT WINAPI UrlGetPartW(const WCHAR *url, WCHAR *out, DWORD *out_len, DWORD p return E_INVALIDARG; }
- if (flags == URL_PARTFLAG_KEEPSCHEME) + if (flags == URL_PARTFLAG_KEEPSCHEME && scheme != URL_SCHEME_FILE) { if (!pl.scheme || !pl.scheme_len) { diff --git a/dlls/shlwapi/tests/url.c b/dlls/shlwapi/tests/url.c index b2b20b94b1b..4fb4e36c3b6 100644 --- a/dlls/shlwapi/tests/url.c +++ b/dlls/shlwapi/tests/url.c @@ -683,7 +683,7 @@ static void test_UrlGetPart(void) {"http:///index.html", URL_PART_HOSTNAME, 0, S_FALSE, ""}, {"http:///index.html", URL_PART_HOSTNAME, URL_PARTFLAG_KEEPSCHEME, S_OK, "http:", .todo_hr = TRUE}, {"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", .todo_result = TRUE}, + {"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}, {"file://foo:bar@localhost:21/file?query=x", URL_PART_PASSWORD, 0, E_FAIL, .todo_hr = TRUE}, {"file://foo:bar@localhost:21/file?query=x", URL_PART_HOSTNAME, 0, S_OK, "foo:bar@localhost:21", .todo_result = TRUE}, @@ -737,7 +737,7 @@ static void test_UrlGetPart(void) {"vbscript://hostname/", URL_PART_HOSTNAME, 0, E_FAIL}, {"wais://hostname/", URL_PART_HOSTNAME, 0, E_FAIL},
- {"file://hostname/", URL_PART_HOSTNAME, URL_PARTFLAG_KEEPSCHEME, S_OK, "hostname", .todo_result = TRUE}, + {"file://hostname/", URL_PART_HOSTNAME, URL_PARTFLAG_KEEPSCHEME, S_OK, "hostname"}, {"ftp://hostname/", URL_PART_HOSTNAME, URL_PARTFLAG_KEEPSCHEME, S_OK, "ftp:hostname"}, {"gopher://hostname/", URL_PART_HOSTNAME, URL_PARTFLAG_KEEPSCHEME, S_OK, "gopher:hostname"}, {"http://hostname/", URL_PART_HOSTNAME, URL_PARTFLAG_KEEPSCHEME, S_OK, "http:hostname"},
Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- dlls/kernelbase/path.c | 11 +++++++---- dlls/shlwapi/tests/url.c | 15 +++++++-------- 2 files changed, 14 insertions(+), 12 deletions(-)
diff --git a/dlls/kernelbase/path.c b/dlls/kernelbase/path.c index c3d3e734cf7..7d145e5198e 100644 --- a/dlls/kernelbase/path.c +++ b/dlls/kernelbase/path.c @@ -4347,12 +4347,15 @@ HRESULT WINAPI UrlGetPartW(const WCHAR *url, WCHAR *out, DWORD *out_len, DWORD p case URL_PART_HOSTNAME: switch (scheme) { - case URL_SCHEME_FTP: - case URL_SCHEME_HTTP: - case URL_SCHEME_GOPHER: - case URL_SCHEME_TELNET: case URL_SCHEME_FILE: + case URL_SCHEME_FTP: + case URL_SCHEME_GOPHER: + case URL_SCHEME_HTTP: case URL_SCHEME_HTTPS: + case URL_SCHEME_TELNET: + case URL_SCHEME_NEWS: + case URL_SCHEME_NNTP: + case URL_SCHEME_SNEWS: break; default: *out_len = 0; diff --git a/dlls/shlwapi/tests/url.c b/dlls/shlwapi/tests/url.c index 4fb4e36c3b6..6a312ecff87 100644 --- a/dlls/shlwapi/tests/url.c +++ b/dlls/shlwapi/tests/url.c @@ -728,11 +728,11 @@ static void test_UrlGetPart(void) {"local://hostname/", URL_PART_HOSTNAME, 0, E_FAIL}, {"mailto://hostname/", URL_PART_HOSTNAME, 0, E_FAIL}, {"mk://hostname/", URL_PART_HOSTNAME, 0, E_FAIL}, - {"news://hostname/", URL_PART_HOSTNAME, 0, S_OK, "hostname", .todo_hr = TRUE}, - {"nntp://hostname/", URL_PART_HOSTNAME, 0, S_OK, "hostname", .todo_hr = TRUE}, + {"news://hostname/", URL_PART_HOSTNAME, 0, S_OK, "hostname"}, + {"nntp://hostname/", URL_PART_HOSTNAME, 0, S_OK, "hostname"}, {"res://hostname/", URL_PART_HOSTNAME, 0, E_FAIL}, {"shell://hostname/", URL_PART_HOSTNAME, 0, E_FAIL}, - {"snews://hostname/", URL_PART_HOSTNAME, 0, S_OK, "hostname", .todo_hr = TRUE}, + {"snews://hostname/", URL_PART_HOSTNAME, 0, S_OK, "hostname"}, {"telnet://hostname/", URL_PART_HOSTNAME, 0, S_OK, "hostname"}, {"vbscript://hostname/", URL_PART_HOSTNAME, 0, E_FAIL}, {"wais://hostname/", URL_PART_HOSTNAME, 0, E_FAIL}, @@ -742,9 +742,9 @@ static void test_UrlGetPart(void) {"gopher://hostname/", URL_PART_HOSTNAME, URL_PARTFLAG_KEEPSCHEME, S_OK, "gopher:hostname"}, {"http://hostname/", URL_PART_HOSTNAME, URL_PARTFLAG_KEEPSCHEME, S_OK, "http:hostname"}, {"https://hostname/", URL_PART_HOSTNAME, URL_PARTFLAG_KEEPSCHEME, S_OK, "https:hostname"}, - {"news://hostname/", URL_PART_HOSTNAME, URL_PARTFLAG_KEEPSCHEME, S_OK, "news:hostname", .todo_hr = TRUE}, - {"nntp://hostname/", URL_PART_HOSTNAME, URL_PARTFLAG_KEEPSCHEME, S_OK, "nntp:hostname", .todo_hr = TRUE}, - {"snews://hostname/", URL_PART_HOSTNAME, URL_PARTFLAG_KEEPSCHEME, S_OK, "snews:hostname", .todo_hr = TRUE}, + {"news://hostname/", URL_PART_HOSTNAME, URL_PARTFLAG_KEEPSCHEME, S_OK, "news:hostname"}, + {"nntp://hostname/", URL_PART_HOSTNAME, URL_PARTFLAG_KEEPSCHEME, S_OK, "nntp:hostname"}, + {"snews://hostname/", URL_PART_HOSTNAME, URL_PARTFLAG_KEEPSCHEME, S_OK, "snews:hostname"}, {"telnet://hostname/", URL_PART_HOSTNAME, URL_PARTFLAG_KEEPSCHEME, S_OK, "telnet:hostname"}, };
@@ -876,8 +876,7 @@ static void test_UrlGetPart(void) { ok(size == wcslen(bufferW), "Got size %u.\n", size); MultiByteToWideChar(CP_ACP, 0, buffer, -1, expectW, ARRAY_SIZE(expectW)); - todo_wine_if (strstr(url, "news") || strstr(url, "nntp")) - ok(!wcscmp(bufferW, expectW), "Got result %s.\n", debugstr_w(bufferW)); + ok(!wcscmp(bufferW, expectW), "Got result %s.\n", debugstr_w(bufferW)); } else {
Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- dlls/kernelbase/path.c | 14 +++++++------- dlls/shlwapi/tests/url.c | 13 ++++++++----- 2 files changed, 15 insertions(+), 12 deletions(-)
diff --git a/dlls/kernelbase/path.c b/dlls/kernelbase/path.c index 7d145e5198e..b753ce3dd2e 100644 --- a/dlls/kernelbase/path.c +++ b/dlls/kernelbase/path.c @@ -4321,8 +4321,6 @@ HRESULT WINAPI UrlGetPartW(const WCHAR *url, WCHAR *out, DWORD *out_len, DWORD p if (!url || !out || !out_len || !*out_len) return E_INVALIDARG;
- *out = '\0'; - addr = wcschr(url, ':'); if (!addr) scheme = URL_SCHEME_UNKNOWN; @@ -4337,6 +4335,7 @@ HRESULT WINAPI UrlGetPartW(const WCHAR *url, WCHAR *out, DWORD *out_len, DWORD p flags &= ~URL_PARTFLAG_KEEPSCHEME; if (!pl.scheme_len) { + *out = '\0'; *out_len = 0; return S_FALSE; } @@ -4358,18 +4357,19 @@ HRESULT WINAPI UrlGetPartW(const WCHAR *url, WCHAR *out, DWORD *out_len, DWORD p case URL_SCHEME_SNEWS: break; default: - *out_len = 0; return E_FAIL; }
if (scheme == URL_SCHEME_FILE && (!pl.hostname_len || (pl.hostname_len == 1 && *(pl.hostname + 1) == ':'))) { + *out = '\0'; *out_len = 0; return S_FALSE; }
if (!pl.hostname_len) { + *out = '\0'; *out_len = 0; return S_FALSE; } @@ -4380,6 +4380,7 @@ HRESULT WINAPI UrlGetPartW(const WCHAR *url, WCHAR *out, DWORD *out_len, DWORD p case URL_PART_USERNAME: if (!pl.username_len) { + *out = '\0'; *out_len = 0; return S_FALSE; } @@ -4390,6 +4391,7 @@ HRESULT WINAPI UrlGetPartW(const WCHAR *url, WCHAR *out, DWORD *out_len, DWORD p case URL_PART_PASSWORD: if (!pl.password_len) { + *out = '\0'; *out_len = 0; return S_FALSE; } @@ -4400,6 +4402,7 @@ HRESULT WINAPI UrlGetPartW(const WCHAR *url, WCHAR *out, DWORD *out_len, DWORD p case URL_PART_PORT: if (!pl.port_len) { + *out = '\0'; *out_len = 0; return S_FALSE; } @@ -4411,6 +4414,7 @@ HRESULT WINAPI UrlGetPartW(const WCHAR *url, WCHAR *out, DWORD *out_len, DWORD p flags &= ~URL_PARTFLAG_KEEPSCHEME; if (!pl.query_len) { + *out = '\0'; *out_len = 0; return S_FALSE; } @@ -4419,17 +4423,13 @@ HRESULT WINAPI UrlGetPartW(const WCHAR *url, WCHAR *out, DWORD *out_len, DWORD p break;
default: - *out_len = 0; return E_INVALIDARG; }
if (flags == URL_PARTFLAG_KEEPSCHEME && scheme != URL_SCHEME_FILE) { if (!pl.scheme || !pl.scheme_len) - { - *out_len = 0; return E_FAIL; - } schaddr = pl.scheme; schsize = pl.scheme_len; if (*out_len < schsize + size + 2) diff --git a/dlls/shlwapi/tests/url.c b/dlls/shlwapi/tests/url.c index 6a312ecff87..729b069a772 100644 --- a/dlls/shlwapi/tests/url.c +++ b/dlls/shlwapi/tests/url.c @@ -845,7 +845,7 @@ static void test_UrlGetPart(void) ok(hr == (tests[i].hr == S_FALSE ? S_OK : tests[i].hr), "Got hr %#x.\n", hr); }
- if (hr == S_OK) + if (SUCCEEDED(hr)) { ok(!size, "Got size %u.\n", size); ok(!buffer[0], "Got result %s.\n", debugstr_a(buffer)); @@ -862,9 +862,9 @@ static void test_UrlGetPart(void) } else { - todo_wine ok(size == 1, "Got size %u.\n", size); + ok(size == 1, "Got size %u.\n", size); } - todo_wine 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); @@ -880,8 +880,11 @@ static void test_UrlGetPart(void) } else { - todo_wine ok(size == ARRAY_SIZE(bufferW), "Got size %u.\n", size); - todo_wine ok(!wcscmp(bufferW, L"x"), "Got result %s.\n", debugstr_w(bufferW)); + todo_wine_if (strchr(url, '"') && part == URL_PART_USERNAME) + { + ok(size == ARRAY_SIZE(bufferW), "Got size %u.\n", size); + ok(!wcscmp(bufferW, L"x"), "Got result %s.\n", debugstr_w(bufferW)); + } }
winetest_pop_context();