Commit 58efbe97 authored by Louis Lenders's avatar Louis Lenders Committed by Alexandre Julliard

shlwapi: Fix UrlUnEscape to expand URLs in-place even if the output buffer is NULL.

parent d571636d
...@@ -937,21 +937,17 @@ static void test_UrlUnescape(void) ...@@ -937,21 +937,17 @@ static void test_UrlUnescape(void)
ok(!strcmp(inplace, expected), "got %s expected %s\n", inplace, expected); ok(!strcmp(inplace, expected), "got %s expected %s\n", inplace, expected);
ok(dwEscaped == 27, "got %d expected 27\n", dwEscaped); ok(dwEscaped == 27, "got %d expected 27\n", dwEscaped);
todo_wine {
/* if we set the bufferpointer to NULL, the string apparently still gets converted (Google Lively does this)) */ /* if we set the bufferpointer to NULL, the string apparently still gets converted (Google Lively does this)) */
ok(UrlUnescapeA(another_inplace, NULL, NULL, URL_UNESCAPE_INPLACE) == S_OK, "UrlUnescapeA failed unexpectedly\n"); ok(UrlUnescapeA(another_inplace, NULL, NULL, URL_UNESCAPE_INPLACE) == S_OK, "UrlUnescapeA failed unexpectedly\n");
ok(!strcmp(another_inplace, expected), "got %s expected %s\n", another_inplace, expected); ok(!strcmp(another_inplace, expected), "got %s expected %s\n", another_inplace, expected);
}
dwEscaped = sizeof(inplaceW); dwEscaped = sizeof(inplaceW);
ok(UrlUnescapeW(inplaceW, NULL, &dwEscaped, URL_UNESCAPE_INPLACE) == S_OK, "UrlUnescapeW failed unexpectedly\n"); ok(UrlUnescapeW(inplaceW, NULL, &dwEscaped, URL_UNESCAPE_INPLACE) == S_OK, "UrlUnescapeW failed unexpectedly\n");
ok(dwEscaped == 50, "got %d expected 50\n", dwEscaped); ok(dwEscaped == 50, "got %d expected 50\n", dwEscaped);
todo_wine {
/* if we set the bufferpointer to NULL, the string apparently still gets converted (Google Lively does this)) */ /* if we set the bufferpointer to NULL, the string apparently still gets converted (Google Lively does this)) */
ok(UrlUnescapeW(another_inplaceW, NULL, NULL, URL_UNESCAPE_INPLACE) == S_OK, "UrlUnescapeW failed unexpectedly\n"); ok(UrlUnescapeW(another_inplaceW, NULL, NULL, URL_UNESCAPE_INPLACE) == S_OK, "UrlUnescapeW failed unexpectedly\n");
ok(lstrlenW(another_inplaceW) == 24, "got %d expected 24\n", lstrlenW(another_inplaceW)); ok(lstrlenW(another_inplaceW) == 24, "got %d expected 24\n", lstrlenW(another_inplaceW));
}
} }
......
...@@ -1155,13 +1155,15 @@ HRESULT WINAPI UrlUnescapeA( ...@@ -1155,13 +1155,15 @@ HRESULT WINAPI UrlUnescapeA(
TRACE("(%s, %p, %p, 0x%08x)\n", debugstr_a(pszUrl), pszUnescaped, TRACE("(%s, %p, %p, 0x%08x)\n", debugstr_a(pszUrl), pszUnescaped,
pcchUnescaped, dwFlags); pcchUnescaped, dwFlags);
if(!pszUrl || (!pszUnescaped && !(dwFlags & URL_UNESCAPE_INPLACE)) || !pcchUnescaped) if (!pszUrl) return E_INVALIDARG;
return E_INVALIDARG;
if(dwFlags & URL_UNESCAPE_INPLACE) if(dwFlags & URL_UNESCAPE_INPLACE)
dst = pszUrl; dst = pszUrl;
else else
{
if (!pszUnescaped || !pcchUnescaped) return E_INVALIDARG;
dst = pszUnescaped; dst = pszUnescaped;
}
for(src = pszUrl, needed = 0; *src; src++, needed++) { for(src = pszUrl, needed = 0; *src; src++, needed++) {
if(dwFlags & URL_DONT_UNESCAPE_EXTRA_INFO && if(dwFlags & URL_DONT_UNESCAPE_EXTRA_INFO &&
...@@ -1222,13 +1224,15 @@ HRESULT WINAPI UrlUnescapeW( ...@@ -1222,13 +1224,15 @@ HRESULT WINAPI UrlUnescapeW(
TRACE("(%s, %p, %p, 0x%08x)\n", debugstr_w(pszUrl), pszUnescaped, TRACE("(%s, %p, %p, 0x%08x)\n", debugstr_w(pszUrl), pszUnescaped,
pcchUnescaped, dwFlags); pcchUnescaped, dwFlags);
if(!pszUrl || (!pszUnescaped && !(dwFlags & URL_UNESCAPE_INPLACE))|| !pcchUnescaped) if(!pszUrl) return E_INVALIDARG;
return E_INVALIDARG;
if(dwFlags & URL_UNESCAPE_INPLACE) if(dwFlags & URL_UNESCAPE_INPLACE)
dst = pszUrl; dst = pszUrl;
else else
{
if (!pszUnescaped || !pcchUnescaped) return E_INVALIDARG;
dst = pszUnescaped; dst = pszUnescaped;
}
for(src = pszUrl, needed = 0; *src; src++, needed++) { for(src = pszUrl, needed = 0; *src; src++, needed++) {
if(dwFlags & URL_DONT_UNESCAPE_EXTRA_INFO && if(dwFlags & URL_DONT_UNESCAPE_EXTRA_INFO &&
......
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