shlwapi: Changed UrlEscapeW error paths and add tests.
Signed-off-by: Fabian Maurer <dark.shadow4@web.de> Signed-off-by: Jacek Caban <jacek@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
8c39694882
commit
101edb1f6d
|
@ -930,12 +930,14 @@ static void test_UrlEscapeA(void)
|
|||
|
||||
static void test_UrlEscapeW(void)
|
||||
{
|
||||
static const WCHAR path_test[] = {'/','t','e','s','t',0};
|
||||
static const WCHAR naW[] = {'f','t','p',31,255,250,0x2122,'e','n','d','/',0};
|
||||
static const WCHAR naescapedW[] = {'f','t','p','%','1','F','%','F','F','%','F','A',0x2122,'e','n','d','/',0};
|
||||
static const WCHAR out[] = {'f','o','o','%','2','0','b','a','r',0};
|
||||
WCHAR overwrite[] = {'f','o','o',' ','b','a','r',0,0,0};
|
||||
WCHAR ret_urlW[INTERNET_MAX_URL_LENGTH];
|
||||
DWORD size = 0;
|
||||
WCHAR empty_string[] = {0};
|
||||
DWORD size;
|
||||
HRESULT ret;
|
||||
WCHAR wc;
|
||||
int i;
|
||||
|
@ -945,6 +947,42 @@ static void test_UrlEscapeW(void)
|
|||
return;
|
||||
}
|
||||
|
||||
/* Check error paths */
|
||||
|
||||
ret = UrlEscapeW(path_test, NULL, NULL, URL_ESCAPE_SPACES_ONLY);
|
||||
ok(ret == E_INVALIDARG, "got %x, expected %x\n", ret, E_INVALIDARG);
|
||||
|
||||
size = 0;
|
||||
ret = UrlEscapeW(path_test, NULL, &size, URL_ESCAPE_SPACES_ONLY);
|
||||
ok(ret == E_INVALIDARG, "got %x, expected %x\n", ret, E_INVALIDARG);
|
||||
ok(size == 0, "got %d, expected %d\n", size, 0);
|
||||
|
||||
ret = UrlEscapeW(path_test, empty_string, NULL, URL_ESCAPE_SPACES_ONLY);
|
||||
ok(ret == E_INVALIDARG, "got %x, expected %x\n", ret, E_INVALIDARG);
|
||||
|
||||
size = 0;
|
||||
ret = UrlEscapeW(path_test, empty_string, &size, URL_ESCAPE_SPACES_ONLY);
|
||||
ok(ret == E_INVALIDARG, "got %x, expected %x\n", ret, E_INVALIDARG);
|
||||
ok(size == 0, "got %d, expected %d\n", size, 0);
|
||||
|
||||
ret = UrlEscapeW(path_test, NULL, NULL, URL_ESCAPE_SPACES_ONLY);
|
||||
ok(ret == E_INVALIDARG, "got %x, expected %x\n", ret, E_INVALIDARG);
|
||||
|
||||
size = 1;
|
||||
ret = UrlEscapeW(path_test, NULL, &size, URL_ESCAPE_SPACES_ONLY);
|
||||
ok(ret == E_INVALIDARG, "got %x, expected %x\n", ret, E_INVALIDARG);
|
||||
ok(size == 1, "got %d, expected %d\n", size, 1);
|
||||
|
||||
ret = UrlEscapeW(path_test, empty_string, NULL, URL_ESCAPE_SPACES_ONLY);
|
||||
ok(ret == E_INVALIDARG, "got %x, expected %x\n", ret, E_INVALIDARG);
|
||||
|
||||
size = 1;
|
||||
ret = UrlEscapeW(path_test, empty_string, &size, URL_ESCAPE_SPACES_ONLY);
|
||||
ok(ret == E_POINTER, "got %x, expected %x\n", ret, E_POINTER);
|
||||
ok(size == 6, "got %d, expected %d\n", size, 6);
|
||||
|
||||
/* Check actual escaping */
|
||||
|
||||
size = sizeof(overwrite)/sizeof(WCHAR);
|
||||
ret = pUrlEscapeW(overwrite, overwrite, &size, URL_ESCAPE_SPACES_ONLY);
|
||||
ok(ret == S_OK, "got %x, expected S_OK\n", ret);
|
||||
|
|
|
@ -1089,7 +1089,7 @@ HRESULT WINAPI UrlEscapeW(
|
|||
TRACE("(%p(%s) %p %p 0x%08x)\n", pszUrl, debugstr_w(pszUrl),
|
||||
pszEscaped, pcchEscaped, dwFlags);
|
||||
|
||||
if(!pszUrl || !pcchEscaped)
|
||||
if(!pszUrl || !pcchEscaped || !pszEscaped || *pcchEscaped == 0)
|
||||
return E_INVALIDARG;
|
||||
|
||||
if(dwFlags & ~(URL_ESCAPE_SPACES_ONLY |
|
||||
|
|
Loading…
Reference in New Issue