Commit 085f95ec authored by Troy Rollo's avatar Troy Rollo Committed by Alexandre Julliard

Corrections to UrlIsW and UrlIsA.

URL_IS_OPAQUE results depend only on the scheme, not on the URL. URL_IS_FILEURL also only depends on the scheme ("file:").
parent a21255d1
...@@ -244,9 +244,44 @@ struct { ...@@ -244,9 +244,44 @@ struct {
{"c:\\foo\\bar", FALSE}, {"c:\\foo\\bar", FALSE},
{"foo://foo/bar", TRUE}, {"foo://foo/bar", TRUE},
{"foo\\bar", FALSE}, {"foo\\bar", FALSE},
{"foo.bar", FALSE} {"foo.bar", FALSE},
{"bogusscheme:", TRUE},
{"http:partial", TRUE}
}; };
struct {
char *url;
BOOL expectOpaque;
BOOL expectFile;
} TEST_URLIS_ATTRIBS[] = {
{ "ftp:", FALSE, FALSE },
{ "http:", FALSE, FALSE },
{ "gopher:", FALSE, FALSE },
{ "mailto:", TRUE, FALSE },
{ "news:", FALSE, FALSE },
{ "nntp:", FALSE, FALSE },
{ "telnet:", FALSE, FALSE },
{ "wais:", FALSE, FALSE },
{ "file:", FALSE, TRUE },
{ "mk:", FALSE, FALSE },
{ "https:", FALSE, FALSE },
{ "shell:", TRUE, FALSE },
{ "https:", FALSE, FALSE },
{ "snews:", FALSE, FALSE },
{ "local:", FALSE, FALSE },
{ "javascript:", TRUE, FALSE },
{ "vbscript:", TRUE, FALSE },
{ "about:", TRUE, FALSE },
{ "res:", FALSE, FALSE },
{ "bogusscheme:", FALSE, FALSE },
{ "file:\\\\e:\\b\\c", FALSE, TRUE },
{ "file://e:/b/c", FALSE, TRUE },
{ "http:partial", FALSE, FALSE },
{ "mailto://www.winehq.org/test.html", TRUE, FALSE },
{ "file:partial", FALSE, TRUE }
};
static LPWSTR GetWideString(const char* szString) static LPWSTR GetWideString(const char* szString)
{ {
LPWSTR wszString = (LPWSTR) HeapAlloc(GetProcessHeap(), 0, LPWSTR wszString = (LPWSTR) HeapAlloc(GetProcessHeap(), 0,
...@@ -486,12 +521,41 @@ static void test_UrlIs(void) ...@@ -486,12 +521,41 @@ static void test_UrlIs(void)
{ {
BOOL ret; BOOL ret;
size_t i; size_t i;
WCHAR wurl[80];
for(i = 0; i < sizeof(TEST_PATH_IS_URL) / sizeof(TEST_PATH_IS_URL[0]); i++) { for(i = 0; i < sizeof(TEST_PATH_IS_URL) / sizeof(TEST_PATH_IS_URL[0]); i++) {
MultiByteToWideChar(CP_ACP, 0, TEST_PATH_IS_URL[i].path, -1, wurl, 80);
ret = UrlIsA( TEST_PATH_IS_URL[i].path, URLIS_URL ); ret = UrlIsA( TEST_PATH_IS_URL[i].path, URLIS_URL );
ok( ret == TEST_PATH_IS_URL[i].expect, ok( ret == TEST_PATH_IS_URL[i].expect,
"returned %d from path %s, expected %d\n", ret, TEST_PATH_IS_URL[i].path, "returned %d from path %s, expected %d\n", ret, TEST_PATH_IS_URL[i].path,
TEST_PATH_IS_URL[i].expect ); TEST_PATH_IS_URL[i].expect );
ret = UrlIsW( wurl, URLIS_URL );
ok( ret == TEST_PATH_IS_URL[i].expect,
"returned %d from path (UrlIsW) %s, expected %d\n", ret, TEST_PATH_IS_URL[i].path,
TEST_PATH_IS_URL[i].expect );
}
for(i = 0; i < sizeof(TEST_URLIS_ATTRIBS) / sizeof(TEST_URLIS_ATTRIBS[0]); i++) {
MultiByteToWideChar(CP_ACP, 0, TEST_URLIS_ATTRIBS[i].url, -1, wurl, 80);
ret = UrlIsA( TEST_URLIS_ATTRIBS[i].url, URLIS_OPAQUE);
ok( ret == TEST_URLIS_ATTRIBS[i].expectOpaque,
"returned %d for URLIS_OPAQUE, url \"%s\", expected %d\n", ret, TEST_URLIS_ATTRIBS[i].url,
TEST_URLIS_ATTRIBS[i].expectOpaque );
ret = UrlIsA( TEST_URLIS_ATTRIBS[i].url, URLIS_FILEURL);
ok( ret == TEST_URLIS_ATTRIBS[i].expectFile,
"returned %d for URLIS_FILEURL, url \"%s\", expected %d\n", ret, TEST_URLIS_ATTRIBS[i].url,
TEST_URLIS_ATTRIBS[i].expectFile );
ret = UrlIsW( wurl, URLIS_OPAQUE);
ok( ret == TEST_URLIS_ATTRIBS[i].expectOpaque,
"returned %d for URLIS_OPAQUE (UrlIsW), url \"%s\", expected %d\n", ret, TEST_URLIS_ATTRIBS[i].url,
TEST_URLIS_ATTRIBS[i].expectOpaque );
ret = UrlIsW( wurl, URLIS_FILEURL);
ok( ret == TEST_URLIS_ATTRIBS[i].expectFile,
"returned %d for URLIS_FILEURL (UrlIsW), url \"%s\", expected %d\n", ret, TEST_URLIS_ATTRIBS[i].url,
TEST_URLIS_ATTRIBS[i].expectFile );
} }
} }
......
...@@ -1640,13 +1640,19 @@ BOOL WINAPI UrlIsA(LPCSTR pszUrl, URLIS Urlis) ...@@ -1640,13 +1640,19 @@ BOOL WINAPI UrlIsA(LPCSTR pszUrl, URLIS Urlis)
base.cbSize = sizeof(base); base.cbSize = sizeof(base);
res1 = ParseURLA(pszUrl, &base); res1 = ParseURLA(pszUrl, &base);
if (res1) return FALSE; /* invalid scheme */ if (res1) return FALSE; /* invalid scheme */
if ((*base.pszSuffix == '/') && (*(base.pszSuffix+1) == '/')) switch (base.nScheme)
/* has scheme followed by 2 '/' */ {
return FALSE; case URL_SCHEME_MAILTO:
return TRUE; case URL_SCHEME_SHELL:
case URL_SCHEME_JAVASCRIPT:
case URL_SCHEME_VBSCRIPT:
case URL_SCHEME_ABOUT:
return TRUE;
}
return FALSE;
case URLIS_FILEURL: case URLIS_FILEURL:
return !StrCmpNA("file://", pszUrl, 7); return !StrCmpNA("file:", pszUrl, 5);
case URLIS_DIRECTORY: case URLIS_DIRECTORY:
last = pszUrl + strlen(pszUrl) - 1; last = pszUrl + strlen(pszUrl) - 1;
...@@ -1671,7 +1677,7 @@ BOOL WINAPI UrlIsA(LPCSTR pszUrl, URLIS Urlis) ...@@ -1671,7 +1677,7 @@ BOOL WINAPI UrlIsA(LPCSTR pszUrl, URLIS Urlis)
*/ */
BOOL WINAPI UrlIsW(LPCWSTR pszUrl, URLIS Urlis) BOOL WINAPI UrlIsW(LPCWSTR pszUrl, URLIS Urlis)
{ {
static const WCHAR stemp[] = { 'f','i','l','e',':','/','/',0 }; static const WCHAR stemp[] = { 'f','i','l','e',':',0 };
PARSEDURLW base; PARSEDURLW base;
DWORD res1; DWORD res1;
LPCWSTR last; LPCWSTR last;
...@@ -1684,13 +1690,19 @@ BOOL WINAPI UrlIsW(LPCWSTR pszUrl, URLIS Urlis) ...@@ -1684,13 +1690,19 @@ BOOL WINAPI UrlIsW(LPCWSTR pszUrl, URLIS Urlis)
base.cbSize = sizeof(base); base.cbSize = sizeof(base);
res1 = ParseURLW(pszUrl, &base); res1 = ParseURLW(pszUrl, &base);
if (res1) return FALSE; /* invalid scheme */ if (res1) return FALSE; /* invalid scheme */
if ((*base.pszSuffix == '/') && (*(base.pszSuffix+1) == '/')) switch (base.nScheme)
/* has scheme followed by 2 '/' */ {
return FALSE; case URL_SCHEME_MAILTO:
return TRUE; case URL_SCHEME_SHELL:
case URL_SCHEME_JAVASCRIPT:
case URL_SCHEME_VBSCRIPT:
case URL_SCHEME_ABOUT:
return TRUE;
}
return FALSE;
case URLIS_FILEURL: case URLIS_FILEURL:
return !strncmpW(stemp, pszUrl, 7); return !strncmpW(stemp, pszUrl, 5);
case URLIS_DIRECTORY: case URLIS_DIRECTORY:
last = pszUrl + strlenW(pszUrl) - 1; last = pszUrl + strlenW(pszUrl) - 1;
......
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