shlwapi: Make more strict restriction for URL scheme and fix error handling in ParseURLW.
This commit is contained in:
parent
e57b8526b2
commit
4d592ae84f
@ -131,7 +131,7 @@ static const TEST_URL_CANONICALIZE TEST_CANONICALIZE[] = {
|
|||||||
{"res:///c:\\tests\\foo bar", 0, S_OK, "res:///c:\\tests\\foo bar", TRUE},
|
{"res:///c:\\tests\\foo bar", 0, S_OK, "res:///c:\\tests\\foo bar", TRUE},
|
||||||
{"res:///c:\\tests\\foo bar", URL_DONT_SIMPLIFY, S_OK, "res:///c:\\tests\\foo bar", TRUE},
|
{"res:///c:\\tests\\foo bar", URL_DONT_SIMPLIFY, S_OK, "res:///c:\\tests\\foo bar", TRUE},
|
||||||
{"A", 0, S_OK, "A", FALSE},
|
{"A", 0, S_OK, "A", FALSE},
|
||||||
{"/uri-res/N2R?urn:sha1:B3K", URL_DONT_ESCAPE_EXTRA_INFO | URL_WININET_COMPATIBILITY /*0x82000000*/, S_OK, "/uri-res/N2R?urn:sha1:B3K", TRUE} /*LimeWire online installer calls this*/,
|
{"/uri-res/N2R?urn:sha1:B3K", URL_DONT_ESCAPE_EXTRA_INFO | URL_WININET_COMPATIBILITY /*0x82000000*/, S_OK, "/uri-res/N2R?urn:sha1:B3K", FALSE} /*LimeWire online installer calls this*/,
|
||||||
{"http:www.winehq.org/dir/../index.html", 0, S_OK, "http:www.winehq.org/index.html"},
|
{"http:www.winehq.org/dir/../index.html", 0, S_OK, "http:www.winehq.org/index.html"},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -180,38 +180,26 @@ HRESULT WINAPI ParseURLA(LPCSTR x, PARSEDURLA *y)
|
|||||||
*/
|
*/
|
||||||
HRESULT WINAPI ParseURLW(LPCWSTR x, PARSEDURLW *y)
|
HRESULT WINAPI ParseURLW(LPCWSTR x, PARSEDURLW *y)
|
||||||
{
|
{
|
||||||
DWORD cnt;
|
const WCHAR *ptr = x;
|
||||||
|
|
||||||
y->nScheme = URL_SCHEME_INVALID;
|
TRACE("%s %p\n", debugstr_w(x), y);
|
||||||
if (y->cbSize != sizeof(*y)) return E_INVALIDARG;
|
|
||||||
/* FIXME: leading white space generates error of 0x80041001 which
|
|
||||||
* is undefined
|
|
||||||
*/
|
|
||||||
if (*x <= ' ') return 0x80041001;
|
|
||||||
cnt = 0;
|
|
||||||
y->cchProtocol = 0;
|
|
||||||
y->pszProtocol = x;
|
|
||||||
while (*x) {
|
|
||||||
if (*x == ':') {
|
|
||||||
y->cchProtocol = cnt;
|
|
||||||
cnt = -1;
|
|
||||||
y->pszSuffix = x+1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
x++;
|
|
||||||
cnt++;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* check for no scheme in string start */
|
if(y->cbSize != sizeof(*y))
|
||||||
/* (apparently schemes *must* be larger than a single character) */
|
return E_INVALIDARG;
|
||||||
if ((*x == '\0') || (y->cchProtocol <= 1)) {
|
|
||||||
|
while(*ptr && (isalnumW(*ptr) || *ptr == '-'))
|
||||||
|
ptr++;
|
||||||
|
|
||||||
|
if (*ptr != ':' || ptr <= x+1) {
|
||||||
y->pszProtocol = NULL;
|
y->pszProtocol = NULL;
|
||||||
return 0x80041001;
|
return 0x80041001;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* found scheme, set length of remainder */
|
y->pszProtocol = x;
|
||||||
y->cchSuffix = lstrlenW(y->pszSuffix);
|
y->cchProtocol = ptr-x;
|
||||||
y->nScheme = get_scheme_code(y->pszProtocol, y->cchProtocol);
|
y->pszSuffix = ptr+1;
|
||||||
|
y->cchSuffix = strlenW(y->pszSuffix);
|
||||||
|
y->nScheme = get_scheme_code(x, ptr-x);
|
||||||
|
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user