Commit 101edb1f authored by Fabian Maurer's avatar Fabian Maurer Committed by Alexandre Julliard

shlwapi: Changed UrlEscapeW error paths and add tests.

parent 8c396948
......@@ -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 |
......
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