shlwapi: Make more strict restriction for URL scheme and fix error handling in ParseURLA.
This commit is contained in:
parent
a34ed0f6ee
commit
e57b8526b2
|
@ -145,40 +145,29 @@ static DWORD get_scheme_code(LPCWSTR scheme, DWORD scheme_len)
|
||||||
HRESULT WINAPI ParseURLA(LPCSTR x, PARSEDURLA *y)
|
HRESULT WINAPI ParseURLA(LPCSTR x, PARSEDURLA *y)
|
||||||
{
|
{
|
||||||
WCHAR scheme[INTERNET_MAX_SCHEME_LENGTH];
|
WCHAR scheme[INTERNET_MAX_SCHEME_LENGTH];
|
||||||
DWORD cnt, len;
|
const char *ptr = x;
|
||||||
|
int len;
|
||||||
|
|
||||||
y->nScheme = URL_SCHEME_INVALID;
|
TRACE("%s %p\n", debugstr_a(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 && (isalnum(*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 = lstrlenA(y->pszSuffix);
|
y->cchProtocol = ptr-x;
|
||||||
|
y->pszSuffix = ptr+1;
|
||||||
|
y->cchSuffix = strlen(y->pszSuffix);
|
||||||
|
|
||||||
len = MultiByteToWideChar(CP_ACP, 0, y->pszProtocol, y->cchProtocol,
|
len = MultiByteToWideChar(CP_ACP, 0, x, ptr-x,
|
||||||
scheme, sizeof(scheme)/sizeof(WCHAR));
|
scheme, sizeof(scheme)/sizeof(WCHAR));
|
||||||
y->nScheme = get_scheme_code(scheme, len);
|
y->nScheme = get_scheme_code(scheme, len);
|
||||||
|
|
||||||
return S_OK;
|
return S_OK;
|
||||||
|
|
Loading…
Reference in New Issue