From 9339be641c6e5cfe6dfebe282fcf13d37579a25f Mon Sep 17 00:00:00 2001 From: Aric Stewart Date: Tue, 2 Jun 2009 11:31:50 -0500 Subject: [PATCH] shlwapi: Simplify UrlCombine case 2 with tests. --- dlls/shlwapi/tests/url.c | 23 ++++++++++++++++++++++- dlls/shlwapi/url.c | 22 +--------------------- 2 files changed, 23 insertions(+), 22 deletions(-) diff --git a/dlls/shlwapi/tests/url.c b/dlls/shlwapi/tests/url.c index 80aee98c55a..f135f2a1e19 100644 --- a/dlls/shlwapi/tests/url.c +++ b/dlls/shlwapi/tests/url.c @@ -263,7 +263,28 @@ static const TEST_URL_COMBINE TEST_COMBINE[] = { {"foo:/today", "foo:calendar", 0, S_OK, "foo:/calendar"}, {"foo:/today/", "foo:calendar", 0, S_OK, "foo:/today/calendar"}, {"mk:@MSITStore:dir/test.chm::dir/index.html", "image.jpg", 0, S_OK, "mk:@MSITStore:dir/test.chm::dir/image.jpg"}, - {"mk:@MSITStore:dir/test.chm::dir/dir2/index.html", "../image.jpg", 0, S_OK, "mk:@MSITStore:dir/test.chm::dir/image.jpg"} + {"mk:@MSITStore:dir/test.chm::dir/dir2/index.html", "../image.jpg", 0, S_OK, "mk:@MSITStore:dir/test.chm::dir/image.jpg"}, + /* UrlCombine case 2 tests. Schemes do not match */ + {"outbind://xxxxxxxxx","http://wine1/dir",0, S_OK,"http://wine1/dir"}, + {"xxxx://xxxxxxxxx","http://wine2/dir",0, S_OK,"http://wine2/dir"}, + {"ftp://xxxxxxxxx/","http://wine3/dir",0, S_OK,"http://wine3/dir"}, + {"outbind://xxxxxxxxx","http://wine4/dir",URL_PLUGGABLE_PROTOCOL, S_OK,"http://wine4/dir"}, + {"xxx://xxxxxxxxx","http://wine5/dir",URL_PLUGGABLE_PROTOCOL, S_OK,"http://wine5/dir"}, + {"ftp://xxxxxxxxx/","http://wine6/dir",URL_PLUGGABLE_PROTOCOL, S_OK,"http://wine6/dir"}, + {"http://xxxxxxxxx","outbind://wine7/dir",0, S_OK,"outbind://wine7/dir"}, + {"xxx://xxxxxxxxx","ftp://wine8/dir",0, S_OK,"ftp://wine8/dir"}, + {"ftp://xxxxxxxxx/","xxx://wine9/dir",0, S_OK,"xxx://wine9/dir"}, + {"http://xxxxxxxxx","outbind://wine10/dir",URL_PLUGGABLE_PROTOCOL, S_OK,"outbind://wine10/dir"}, + {"xxx://xxxxxxxxx","ftp://wine11/dir",URL_PLUGGABLE_PROTOCOL, S_OK,"ftp://wine11/dir"}, + {"ftp://xxxxxxxxx/","xxx://wine12/dir",URL_PLUGGABLE_PROTOCOL, S_OK,"xxx://wine12/dir"}, + {"http://xxxxxxxxx","outbind:wine13/dir",0, S_OK,"outbind:wine13/dir"}, + {"xxx://xxxxxxxxx","ftp:wine14/dir",0, S_OK,"ftp:wine14/dir"}, + {"ftp://xxxxxxxxx/","xxx:wine15/dir",0, S_OK,"xxx:wine15/dir"}, + {"outbind://xxxxxxxxx/","http:wine16/dir",0, S_OK,"http:wine16/dir"}, + {"http://xxxxxxxxx","outbind:wine17/dir",URL_PLUGGABLE_PROTOCOL, S_OK,"outbind:wine17/dir"}, + {"xxx://xxxxxxxxx","ftp:wine18/dir",URL_PLUGGABLE_PROTOCOL, S_OK,"ftp:wine18/dir"}, + {"ftp://xxxxxxxxx/","xxx:wine19/dir",URL_PLUGGABLE_PROTOCOL, S_OK,"xxx:wine19/dir"}, + {"outbind://xxxxxxxxx/","http:wine20/dir",URL_PLUGGABLE_PROTOCOL, S_OK,"http:wine20/dir"} }; /* ################ */ diff --git a/dlls/shlwapi/url.c b/dlls/shlwapi/url.c index 4a39726159d..64988625bdc 100644 --- a/dlls/shlwapi/url.c +++ b/dlls/shlwapi/url.c @@ -129,19 +129,6 @@ static DWORD get_scheme_code(LPCWSTR scheme, DWORD scheme_len) return URL_SCHEME_UNKNOWN; } -static BOOL URL_JustLocation(LPCWSTR str) -{ - while(*str && (*str == '/')) str++; - if (*str) { - while (*str && ((*str == '-') || - (*str == '.') || - isalnumW(*str))) str++; - if (*str == '/') return FALSE; - } - return TRUE; -} - - /************************************************************************* * @ [SHLWAPI.1] * @@ -608,7 +595,6 @@ HRESULT WINAPI UrlCombineW(LPCWSTR pszBase, LPCWSTR pszRelative, DWORD len, res1, res2, process_case = 0; LPWSTR work, preliminary, mbase, mrelative; static const WCHAR myfilestr[] = {'f','i','l','e',':','/','/','/','\0'}; - static const WCHAR single_slash[] = {'/','\0'}; HRESULT ret; TRACE("(base %s, Relative %s, Combine size %d, flags %08x)\n", @@ -768,14 +754,8 @@ HRESULT WINAPI UrlCombineW(LPCWSTR pszBase, LPCWSTR pszRelative, strcatW(preliminary, mrelative); break; - case 2: /* - * Same as case 1, but if URL_PLUGGABLE_PROTOCOL was specified - * and pszRelative starts with "//", then append a "/" - */ + case 2: /* case where pszRelative replaces scheme, and location */ strcpyW(preliminary, mrelative); - if (!(dwFlags & URL_PLUGGABLE_PROTOCOL) && - URL_JustLocation(relative.pszSuffix)) - strcatW(preliminary, single_slash); break; case 3: /*