Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- dlls/kernelbase/path.c | 12 +++++------- dlls/shlwapi/tests/url.c | 2 +- 2 files changed, 6 insertions(+), 8 deletions(-)
diff --git a/dlls/kernelbase/path.c b/dlls/kernelbase/path.c index d14316f05ee..35cce74ab24 100644 --- a/dlls/kernelbase/path.c +++ b/dlls/kernelbase/path.c @@ -4243,15 +4243,13 @@ static LONG parse_url(const WCHAR *url, struct parsed_url *pl) work = parse_url_element( pl->port, L"/\?#" ); pl->port_len = work - pl->port; } - if (*work == '/') + + if ((pl->query = wcschr( work, '?' ))) { - /* see if query string */ - if ((pl->query = wcschr( work, '?' ))) - { - ++pl->query; - pl->query_len = lstrlenW(pl->query); - } + ++pl->query; + pl->query_len = lstrlenW(pl->query); } + SuccessExit: TRACE("parse successful: scheme=%p(%ld), user=%p(%ld), pass=%p(%ld), host=%p(%ld), port=%p(%ld), query=%p(%ld)\n", pl->scheme, pl->scheme_len, pl->username, pl->username_len, pl->password, pl->password_len, pl->hostname, diff --git a/dlls/shlwapi/tests/url.c b/dlls/shlwapi/tests/url.c index 1b26204a94f..3bfd8961c8f 100644 --- a/dlls/shlwapi/tests/url.c +++ b/dlls/shlwapi/tests/url.c @@ -669,7 +669,7 @@ static void test_UrlGetPart(void) {"ftp:\/localhost/index.html", URL_PART_HOSTNAME, 0, S_OK, "localhost", .todo_hr = TRUE},
{"http://host?a:b@c:d", URL_PART_HOSTNAME, 0, S_OK, "host"}, - {"http://host?a:b@c:d", URL_PART_QUERY, 0, S_OK, "a:b@c:d", .todo_hr = TRUE}, + {"http://host?a:b@c:d", URL_PART_QUERY, 0, S_OK, "a:b@c:d"}, {"http://host#a:b@c:d", URL_PART_HOSTNAME, 0, S_OK, "host"}, {"http://host#a:b@c:d", URL_PART_QUERY, 0, S_FALSE, ""},
If we cannot parse a scheme, the entire parsed_url structure will be zero, in which case we will always return S_FALSE from UrlGetPartW().
Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- dlls/kernelbase/path.c | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-)
diff --git a/dlls/kernelbase/path.c b/dlls/kernelbase/path.c index 35cce74ab24..be487e71a3a 100644 --- a/dlls/kernelbase/path.c +++ b/dlls/kernelbase/path.c @@ -4191,16 +4191,16 @@ static const WCHAR *parse_url_element( const WCHAR *url, const WCHAR *separators return url + wcslen( url ); }
-static LONG parse_url(const WCHAR *url, struct parsed_url *pl) +static void parse_url( const WCHAR *url, struct parsed_url *pl ) { const WCHAR *work;
memset(pl, 0, sizeof(*pl)); pl->scheme = url; work = scan_url(pl->scheme, &pl->scheme_len, SCHEME); - if (!*work || (*work != ':')) goto ErrorExit; + if (!*work || (*work != ':')) return; work++; - if ((*work != '/') || (*(work+1) != '/')) goto SuccessExit; + if ((*work != '/') || (*(work+1) != '/')) return;
pl->username = work + 2; work = parse_url_element( pl->username, L":@/\?#" ); @@ -4249,17 +4249,6 @@ static LONG parse_url(const WCHAR *url, struct parsed_url *pl) ++pl->query; pl->query_len = lstrlenW(pl->query); } - - SuccessExit: - TRACE("parse successful: scheme=%p(%ld), user=%p(%ld), pass=%p(%ld), host=%p(%ld), port=%p(%ld), query=%p(%ld)\n", - pl->scheme, pl->scheme_len, pl->username, pl->username_len, pl->password, pl->password_len, pl->hostname, - pl->hostname_len, pl->port, pl->port_len, pl->query, pl->query_len); - - return S_OK; - - ErrorExit: - FIXME("failed to parse %s\n", debugstr_w(url)); - return E_INVALIDARG; }
HRESULT WINAPI UrlGetPartW(const WCHAR *url, WCHAR *out, DWORD *out_len, DWORD part, DWORD flags) @@ -4267,7 +4256,6 @@ HRESULT WINAPI UrlGetPartW(const WCHAR *url, WCHAR *out, DWORD *out_len, DWORD p DWORD scheme, size, schsize; LPCWSTR addr, schaddr; struct parsed_url pl; - HRESULT hr;
TRACE("%s, %p, %p(%ld), %#lx, %#lx\n", wine_dbgstr_w(url), out, out_len, *out_len, part, flags);
@@ -4280,7 +4268,7 @@ HRESULT WINAPI UrlGetPartW(const WCHAR *url, WCHAR *out, DWORD *out_len, DWORD p else scheme = get_scheme_code(url, addr - url);
- hr = parse_url(url, &pl); + parse_url(url, &pl);
switch (scheme) { @@ -4411,7 +4399,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 hr; + return S_OK; }
BOOL WINAPI UrlIsA(const char *url, URLIS Urlis)
Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- dlls/kernelbase/path.c | 2 ++ dlls/shlwapi/tests/url.c | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/dlls/kernelbase/path.c b/dlls/kernelbase/path.c index be487e71a3a..ad823cae547 100644 --- a/dlls/kernelbase/path.c +++ b/dlls/kernelbase/path.c @@ -4321,6 +4321,8 @@ HRESULT WINAPI UrlGetPartW(const WCHAR *url, WCHAR *out, DWORD *out_len, DWORD p break;
case URL_PART_USERNAME: + if (!pl.username) + return E_INVALIDARG; if (!pl.username_len) { *out = '\0'; diff --git a/dlls/shlwapi/tests/url.c b/dlls/shlwapi/tests/url.c index 3bfd8961c8f..5d982467cea 100644 --- a/dlls/shlwapi/tests/url.c +++ b/dlls/shlwapi/tests/url.c @@ -621,13 +621,13 @@ static void test_UrlGetPart(void) {"http://foo:bar@localhost:21/internal.php?query=x&return=y", URL_PART_PORT, URL_PARTFLAG_KEEPSCHEME, S_OK, "http:21"}, {"http://foo:bar@localhost:21/internal.php?query=x&return=y", URL_PART_QUERY, URL_PARTFLAG_KEEPSCHEME, S_OK, "query=x&return=y"},
- {"http://localhost/", URL_PART_USERNAME, 0, E_INVALIDARG, .todo_hr = TRUE}, + {"http://localhost/", URL_PART_USERNAME, 0, E_INVALIDARG}, {"http://localhost/", URL_PART_PASSWORD, 0, E_INVALIDARG, .todo_hr = TRUE}, {"http://localhost/", URL_PART_HOSTNAME, 0, S_OK, "localhost"}, {"http://localhost/", URL_PART_PORT, 0, E_INVALIDARG, .todo_hr = TRUE}, {"http://localhost/", URL_PART_QUERY, 0, S_FALSE, ""},
- {"http://localhost:port/", URL_PART_USERNAME, 0, E_INVALIDARG, .todo_hr = TRUE}, + {"http://localhost:port/", URL_PART_USERNAME, 0, E_INVALIDARG}, {"http://localhost:port/", URL_PART_PASSWORD, 0, E_INVALIDARG, .todo_hr = TRUE}, {"http://localhost:port/", URL_PART_HOSTNAME, 0, S_OK, "localhost"}, {"http://localhost:port/", URL_PART_PORT, 0, S_OK, "port"},
Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- dlls/kernelbase/path.c | 2 ++ dlls/shlwapi/tests/url.c | 8 ++++---- 2 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/dlls/kernelbase/path.c b/dlls/kernelbase/path.c index ad823cae547..fbb4c5152a9 100644 --- a/dlls/kernelbase/path.c +++ b/dlls/kernelbase/path.c @@ -4334,6 +4334,8 @@ HRESULT WINAPI UrlGetPartW(const WCHAR *url, WCHAR *out, DWORD *out_len, DWORD p break;
case URL_PART_PASSWORD: + if (!pl.password) + return E_INVALIDARG; if (!pl.password_len) { *out = '\0'; diff --git a/dlls/shlwapi/tests/url.c b/dlls/shlwapi/tests/url.c index 5d982467cea..54342d1e5c2 100644 --- a/dlls/shlwapi/tests/url.c +++ b/dlls/shlwapi/tests/url.c @@ -622,24 +622,24 @@ static void test_UrlGetPart(void) {"http://foo:bar@localhost:21/internal.php?query=x&return=y", URL_PART_QUERY, URL_PARTFLAG_KEEPSCHEME, S_OK, "query=x&return=y"},
{"http://localhost/", URL_PART_USERNAME, 0, E_INVALIDARG}, - {"http://localhost/", URL_PART_PASSWORD, 0, E_INVALIDARG, .todo_hr = TRUE}, + {"http://localhost/", URL_PART_PASSWORD, 0, E_INVALIDARG}, {"http://localhost/", URL_PART_HOSTNAME, 0, S_OK, "localhost"}, {"http://localhost/", URL_PART_PORT, 0, E_INVALIDARG, .todo_hr = TRUE}, {"http://localhost/", URL_PART_QUERY, 0, S_FALSE, ""},
{"http://localhost:port/", URL_PART_USERNAME, 0, E_INVALIDARG}, - {"http://localhost:port/", URL_PART_PASSWORD, 0, E_INVALIDARG, .todo_hr = TRUE}, + {"http://localhost:port/", URL_PART_PASSWORD, 0, E_INVALIDARG}, {"http://localhost:port/", URL_PART_HOSTNAME, 0, S_OK, "localhost"}, {"http://localhost:port/", URL_PART_PORT, 0, S_OK, "port"}, {"http://:", URL_PART_HOSTNAME, 0, S_FALSE, ""}, {"http://:", URL_PART_PORT, 0, S_FALSE, ""},
{"http://user@localhost", URL_PART_USERNAME, 0, S_OK, "user"}, - {"http://user@localhost", URL_PART_PASSWORD, 0, E_INVALIDARG, .todo_hr = TRUE}, + {"http://user@localhost", URL_PART_PASSWORD, 0, E_INVALIDARG}, {"http://user@localhost", URL_PART_HOSTNAME, 0, S_OK, "localhost"}, {"http://user@localhost", URL_PART_PORT, 0, E_INVALIDARG, .todo_hr = TRUE}, {"http://@", URL_PART_USERNAME, 0, S_FALSE, ""}, - {"http://@", URL_PART_PASSWORD, 0, E_INVALIDARG, .todo_hr = TRUE}, + {"http://@", URL_PART_PASSWORD, 0, E_INVALIDARG}, {"http://@", URL_PART_HOSTNAME, 0, S_FALSE, ""},
{"http://user:pass@localhost", URL_PART_USERNAME, 0, S_OK, "user"},
Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- dlls/kernelbase/path.c | 2 ++ dlls/shlwapi/tests/url.c | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/dlls/kernelbase/path.c b/dlls/kernelbase/path.c index fbb4c5152a9..e29ee585123 100644 --- a/dlls/kernelbase/path.c +++ b/dlls/kernelbase/path.c @@ -4347,6 +4347,8 @@ HRESULT WINAPI UrlGetPartW(const WCHAR *url, WCHAR *out, DWORD *out_len, DWORD p break;
case URL_PART_PORT: + if (!pl.port) + return E_INVALIDARG; if (!pl.port_len) { *out = '\0'; diff --git a/dlls/shlwapi/tests/url.c b/dlls/shlwapi/tests/url.c index 54342d1e5c2..18af0906e08 100644 --- a/dlls/shlwapi/tests/url.c +++ b/dlls/shlwapi/tests/url.c @@ -624,7 +624,7 @@ static void test_UrlGetPart(void) {"http://localhost/", URL_PART_USERNAME, 0, E_INVALIDARG}, {"http://localhost/", URL_PART_PASSWORD, 0, E_INVALIDARG}, {"http://localhost/", URL_PART_HOSTNAME, 0, S_OK, "localhost"}, - {"http://localhost/", URL_PART_PORT, 0, E_INVALIDARG, .todo_hr = TRUE}, + {"http://localhost/", URL_PART_PORT, 0, E_INVALIDARG}, {"http://localhost/", URL_PART_QUERY, 0, S_FALSE, ""},
{"http://localhost:port/", URL_PART_USERNAME, 0, E_INVALIDARG}, @@ -637,7 +637,7 @@ static void test_UrlGetPart(void) {"http://user@localhost", URL_PART_USERNAME, 0, S_OK, "user"}, {"http://user@localhost", URL_PART_PASSWORD, 0, E_INVALIDARG}, {"http://user@localhost", URL_PART_HOSTNAME, 0, S_OK, "localhost"}, - {"http://user@localhost", URL_PART_PORT, 0, E_INVALIDARG, .todo_hr = TRUE}, + {"http://user@localhost", URL_PART_PORT, 0, E_INVALIDARG}, {"http://@", URL_PART_USERNAME, 0, S_FALSE, ""}, {"http://@", URL_PART_PASSWORD, 0, E_INVALIDARG}, {"http://@", URL_PART_HOSTNAME, 0, S_FALSE, ""}, @@ -645,7 +645,7 @@ static void test_UrlGetPart(void) {"http://user:pass@localhost", URL_PART_USERNAME, 0, S_OK, "user"}, {"http://user:pass@localhost", URL_PART_PASSWORD, 0, S_OK, "pass"}, {"http://user:pass@localhost", URL_PART_HOSTNAME, 0, S_OK, "localhost"}, - {"http://user:pass@localhost", URL_PART_PORT, 0, E_INVALIDARG, .todo_hr = TRUE}, + {"http://user:pass@localhost", URL_PART_PORT, 0, E_INVALIDARG}, {"http://:@", URL_PART_USERNAME, 0, S_FALSE, ""}, {"http://:@", URL_PART_PASSWORD, 0, S_FALSE, ""}, {"http://:@", URL_PART_HOSTNAME, 0, S_FALSE, ""},