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:").
This commit is contained in:
Troy Rollo 2005-03-21 10:54:35 +00:00 committed by Alexandre Julliard
parent a21255d102
commit 085f95ec3a
2 changed files with 88 additions and 12 deletions

View File

@ -244,9 +244,44 @@ struct {
{"c:\\foo\\bar", FALSE},
{"foo://foo/bar", TRUE},
{"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)
{
LPWSTR wszString = (LPWSTR) HeapAlloc(GetProcessHeap(), 0,
@ -486,12 +521,41 @@ static void test_UrlIs(void)
{
BOOL ret;
size_t i;
WCHAR wurl[80];
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 );
ok( ret == TEST_PATH_IS_URL[i].expect,
"returned %d from path %s, expected %d\n", ret, TEST_PATH_IS_URL[i].path,
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 );
}
}

View File

@ -1640,13 +1640,19 @@ BOOL WINAPI UrlIsA(LPCSTR pszUrl, URLIS Urlis)
base.cbSize = sizeof(base);
res1 = ParseURLA(pszUrl, &base);
if (res1) return FALSE; /* invalid scheme */
if ((*base.pszSuffix == '/') && (*(base.pszSuffix+1) == '/'))
/* has scheme followed by 2 '/' */
return FALSE;
return TRUE;
switch (base.nScheme)
{
case URL_SCHEME_MAILTO:
case URL_SCHEME_SHELL:
case URL_SCHEME_JAVASCRIPT:
case URL_SCHEME_VBSCRIPT:
case URL_SCHEME_ABOUT:
return TRUE;
}
return FALSE;
case URLIS_FILEURL:
return !StrCmpNA("file://", pszUrl, 7);
return !StrCmpNA("file:", pszUrl, 5);
case URLIS_DIRECTORY:
last = pszUrl + strlen(pszUrl) - 1;
@ -1671,7 +1677,7 @@ BOOL WINAPI UrlIsA(LPCSTR 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;
DWORD res1;
LPCWSTR last;
@ -1684,13 +1690,19 @@ BOOL WINAPI UrlIsW(LPCWSTR pszUrl, URLIS Urlis)
base.cbSize = sizeof(base);
res1 = ParseURLW(pszUrl, &base);
if (res1) return FALSE; /* invalid scheme */
if ((*base.pszSuffix == '/') && (*(base.pszSuffix+1) == '/'))
/* has scheme followed by 2 '/' */
return FALSE;
return TRUE;
switch (base.nScheme)
{
case URL_SCHEME_MAILTO:
case URL_SCHEME_SHELL:
case URL_SCHEME_JAVASCRIPT:
case URL_SCHEME_VBSCRIPT:
case URL_SCHEME_ABOUT:
return TRUE;
}
return FALSE;
case URLIS_FILEURL:
return !strncmpW(stemp, pszUrl, 7);
return !strncmpW(stemp, pszUrl, 5);
case URLIS_DIRECTORY:
last = pszUrl + strlenW(pszUrl) - 1;