Jacek Caban : shlwapi: Make more strict restriction for URL scheme and fix error handling in ParseURLW .
Alexandre Julliard
julliard at winehq.org
Mon Oct 19 09:56:10 CDT 2009
Module: wine
Branch: master
Commit: 4d592ae84fbb16fec55a3e73f7bc1e2b45e85705
URL: http://source.winehq.org/git/wine.git/?a=commit;h=4d592ae84fbb16fec55a3e73f7bc1e2b45e85705
Author: Jacek Caban <jacek at codeweavers.com>
Date: Sun Oct 18 21:49:41 2009 +0200
shlwapi: Make more strict restriction for URL scheme and fix error handling in ParseURLW.
---
dlls/shlwapi/tests/url.c | 2 +-
dlls/shlwapi/url.c | 42 +++++++++++++++---------------------------
2 files changed, 16 insertions(+), 28 deletions(-)
diff --git a/dlls/shlwapi/tests/url.c b/dlls/shlwapi/tests/url.c
index f135f2a..39cf00b 100644
--- a/dlls/shlwapi/tests/url.c
+++ b/dlls/shlwapi/tests/url.c
@@ -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", URL_DONT_SIMPLIFY, S_OK, "res:///c:\\tests\\foo bar", TRUE},
{"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"},
};
diff --git a/dlls/shlwapi/url.c b/dlls/shlwapi/url.c
index 1b8803c..2b7a8cd 100644
--- a/dlls/shlwapi/url.c
+++ b/dlls/shlwapi/url.c
@@ -180,38 +180,26 @@ HRESULT WINAPI ParseURLA(LPCSTR x, PARSEDURLA *y)
*/
HRESULT WINAPI ParseURLW(LPCWSTR x, PARSEDURLW *y)
{
- DWORD cnt;
+ const WCHAR *ptr = x;
- y->nScheme = URL_SCHEME_INVALID;
- 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++;
- }
+ TRACE("%s %p\n", debugstr_w(x), y);
+
+ if(y->cbSize != sizeof(*y))
+ return E_INVALIDARG;
+
+ while(*ptr && (isalnumW(*ptr) || *ptr == '-'))
+ ptr++;
- /* check for no scheme in string start */
- /* (apparently schemes *must* be larger than a single character) */
- if ((*x == '\0') || (y->cchProtocol <= 1)) {
+ if (*ptr != ':' || ptr <= x+1) {
y->pszProtocol = NULL;
return 0x80041001;
}
- /* found scheme, set length of remainder */
- y->cchSuffix = lstrlenW(y->pszSuffix);
- y->nScheme = get_scheme_code(y->pszProtocol, y->cchProtocol);
+ y->pszProtocol = x;
+ y->cchProtocol = ptr-x;
+ y->pszSuffix = ptr+1;
+ y->cchSuffix = strlenW(y->pszSuffix);
+ y->nScheme = get_scheme_code(x, ptr-x);
return S_OK;
}
More information about the wine-cvs
mailing list