Commit 4d592ae8 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

shlwapi: Make more strict restriction for URL scheme and fix error handling in ParseURLW.

parent e57b8526
...@@ -131,7 +131,7 @@ static const TEST_URL_CANONICALIZE TEST_CANONICALIZE[] = { ...@@ -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) ...@@ -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 if(y->cbSize != sizeof(*y))
* is undefined return E_INVALIDARG;
*/
if (*x <= ' ') return 0x80041001; while(*ptr && (isalnumW(*ptr) || *ptr == '-'))
cnt = 0; ptr++;
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 (*ptr != ':' || ptr <= x+1) {
/* (apparently schemes *must* be larger than a single character) */
if ((*x == '\0') || (y->cchProtocol <= 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;
} }
......
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