Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- dlls/kernelbase/path.c | 8 +++++++- dlls/shlwapi/tests/url.c | 8 ++++---- 2 files changed, 11 insertions(+), 5 deletions(-)
diff --git a/dlls/kernelbase/path.c b/dlls/kernelbase/path.c index e29ee585123..befdf237c5e 100644 --- a/dlls/kernelbase/path.c +++ b/dlls/kernelbase/path.c @@ -4191,6 +4191,11 @@ static const WCHAR *parse_url_element( const WCHAR *url, const WCHAR *separators return url + wcslen( url ); }
+static BOOL is_slash( char c ) +{ + return c == '/' || c == '\'; +} + static void parse_url( const WCHAR *url, struct parsed_url *pl ) { const WCHAR *work; @@ -4200,7 +4205,8 @@ static void parse_url( const WCHAR *url, struct parsed_url *pl ) work = scan_url(pl->scheme, &pl->scheme_len, SCHEME); if (!*work || (*work != ':')) return; work++; - if ((*work != '/') || (*(work+1) != '/')) return; + if (!is_slash( work[0] ) || !is_slash( work[1] )) + return;
pl->username = work + 2; work = parse_url_element( pl->username, L":@/\?#" ); diff --git a/dlls/shlwapi/tests/url.c b/dlls/shlwapi/tests/url.c index 18af0906e08..ae0d0738195 100644 --- a/dlls/shlwapi/tests/url.c +++ b/dlls/shlwapi/tests/url.c @@ -661,12 +661,12 @@ static void test_UrlGetPart(void) {"http:/localhost/index.html", URL_PART_HOSTNAME, 0, E_FAIL, .todo_hr = TRUE},
{"http://localhost%5C%5Cindex.html", URL_PART_HOSTNAME, 0, S_OK, "localhost"}, - {"http:/\localhost/index.html", URL_PART_HOSTNAME, 0, S_OK, "localhost", .todo_hr = TRUE}, - {"http:\/localhost/index.html", URL_PART_HOSTNAME, 0, S_OK, "localhost", .todo_hr = TRUE}, + {"http:/\localhost/index.html", URL_PART_HOSTNAME, 0, S_OK, "localhost"}, + {"http:\/localhost/index.html", URL_PART_HOSTNAME, 0, S_OK, "localhost"},
{"ftp://localhost\index.html", URL_PART_HOSTNAME, 0, S_OK, "localhost"}, - {"ftp:/\localhost/index.html", URL_PART_HOSTNAME, 0, S_OK, "localhost", .todo_hr = TRUE}, - {"ftp:\/localhost/index.html", URL_PART_HOSTNAME, 0, S_OK, "localhost", .todo_hr = TRUE}, + {"ftp:/\localhost/index.html", URL_PART_HOSTNAME, 0, S_OK, "localhost"}, + {"ftp:\/localhost/index.html", URL_PART_HOSTNAME, 0, S_OK, "localhost"},
{"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"},
Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- dlls/kernelbase/path.c | 35 +++++++---------------------------- 1 file changed, 7 insertions(+), 28 deletions(-)
diff --git a/dlls/kernelbase/path.c b/dlls/kernelbase/path.c index befdf237c5e..3fdc752938c 100644 --- a/dlls/kernelbase/path.c +++ b/dlls/kernelbase/path.c @@ -74,11 +74,6 @@ struct parsed_url DWORD query_len; /* [out] size of Query (until eos) */ };
-enum url_scan_type -{ - SCHEME, -}; - static WCHAR *heap_strdupAtoW(const char *str) { WCHAR *ret = NULL; @@ -4158,28 +4153,11 @@ HRESULT WINAPI UrlGetPartA(const char *url, char *out, DWORD *out_len, DWORD par return hr; }
-static const WCHAR * scan_url(const WCHAR *start, DWORD *size, enum url_scan_type type) +static const WCHAR *parse_scheme( const WCHAR *p ) { - *size = 0; - - switch (type) - { - case SCHEME: - while ((isalnum( *start ) && !isupper( *start )) || *start == '+' || *start == '-' || *start == '.') - { - start++; - (*size)++; - } - if (*start != ':') - *size = 0; - break; - - default: - FIXME("unknown type %d\n", type); - return L""; - } - - return start; + while ((*p >= 'a' && *p <= 'z') || (*p >= '0' && *p <= '9') || *p == '+' || *p == '-' || *p == '.') + ++p; + return p; }
static const WCHAR *parse_url_element( const WCHAR *url, const WCHAR *separators ) @@ -4202,8 +4180,9 @@ static void parse_url( const WCHAR *url, struct parsed_url *pl )
memset(pl, 0, sizeof(*pl)); pl->scheme = url; - work = scan_url(pl->scheme, &pl->scheme_len, SCHEME); - if (!*work || (*work != ':')) return; + work = parse_scheme( pl->scheme ); + if (*work != ':') return; + pl->scheme_len = work - pl->scheme; work++; if (!is_slash( work[0] ) || !is_slash( work[1] )) return;
Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- dlls/kernelbase/path.c | 15 +++++++++++++-- dlls/shlwapi/tests/url.c | 2 +- 2 files changed, 14 insertions(+), 3 deletions(-)
diff --git a/dlls/kernelbase/path.c b/dlls/kernelbase/path.c index 3fdc752938c..0dba2098391 100644 --- a/dlls/kernelbase/path.c +++ b/dlls/kernelbase/path.c @@ -4155,7 +4155,7 @@ HRESULT WINAPI UrlGetPartA(const char *url, char *out, DWORD *out_len, DWORD par
static const WCHAR *parse_scheme( const WCHAR *p ) { - while ((*p >= 'a' && *p <= 'z') || (*p >= '0' && *p <= '9') || *p == '+' || *p == '-' || *p == '.') + while (isalnum( *p ) || *p == '+' || *p == '-' || *p == '.') ++p; return p; } @@ -4384,7 +4384,18 @@ HRESULT WINAPI UrlGetPartW(const WCHAR *url, WCHAR *out, DWORD *out_len, DWORD p *out_len = size + 1; return E_POINTER; } - memcpy(out, addr, size*sizeof(WCHAR)); + + if (part == URL_PART_SCHEME) + { + unsigned int i; + + for (i = 0; i < size; ++i) + out[i] = tolower( addr[i] ); + } + else + { + memcpy( out, addr, size * sizeof(WCHAR) ); + } out[size] = 0; *out_len = size; } diff --git a/dlls/shlwapi/tests/url.c b/dlls/shlwapi/tests/url.c index ae0d0738195..5c28142bc42 100644 --- a/dlls/shlwapi/tests/url.c +++ b/dlls/shlwapi/tests/url.c @@ -709,7 +709,7 @@ static void test_UrlGetPart(void) {"file://c:\index.htm", URL_PART_HOSTNAME, URL_PARTFLAG_KEEPSCHEME, S_FALSE, ""}, {"file:some text", URL_PART_HOSTNAME, 0, S_FALSE, ""}, {"index.htm", URL_PART_HOSTNAME, 0, E_FAIL}, - {"sChEmE-.+:", URL_PART_SCHEME, 0, S_OK, "scheme-.+", .todo_hr = TRUE}, + {"sChEmE-.+:", URL_PART_SCHEME, 0, S_OK, "scheme-.+"}, {"scheme_:", URL_PART_SCHEME, 0, S_FALSE, ""}, {"scheme :", URL_PART_SCHEME, 0, S_FALSE, ""}, {"sch eme:", URL_PART_SCHEME, 0, S_FALSE, ""},
Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- dlls/kernelbase/path.c | 47 +++++----------------------------------- dlls/shlwapi/tests/url.c | 2 +- 2 files changed, 7 insertions(+), 42 deletions(-)
diff --git a/dlls/kernelbase/path.c b/dlls/kernelbase/path.c index 0dba2098391..f83c68e14f5 100644 --- a/dlls/kernelbase/path.c +++ b/dlls/kernelbase/path.c @@ -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) diff --git a/dlls/shlwapi/tests/url.c b/dlls/shlwapi/tests/url.c index 5c28142bc42..c6c7e26cec6 100644 --- a/dlls/shlwapi/tests/url.c +++ b/dlls/shlwapi/tests/url.c @@ -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},