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

Alexandre Julliard julliard at winehq.org
Thu Aug 28 07:00:55 CDT 2008


Module: wine
Branch: master
Commit: 58efbe97ec7a22c61e65757b8cbb3e9bd4ac75a7
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=58efbe97ec7a22c61e65757b8cbb3e9bd4ac75a7

Author: Louis Lenders <xerox_xerox2000 at yahoo.co.uk>
Date:   Wed Aug 27 09:27:34 2008 -0700

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

---

 dlls/shlwapi/tests/url.c |    4 ----
 dlls/shlwapi/url.c       |   12 ++++++++----
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/dlls/shlwapi/tests/url.c b/dlls/shlwapi/tests/url.c
index 0bff99d..c7c6f8f 100644
--- a/dlls/shlwapi/tests/url.c
+++ b/dlls/shlwapi/tests/url.c
@@ -937,21 +937,17 @@ static void test_UrlUnescape(void)
     ok(!strcmp(inplace, expected), "got %s expected %s\n", inplace, expected);
     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)) */
     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);
-    }
 
     dwEscaped = sizeof(inplaceW);
     ok(UrlUnescapeW(inplaceW, NULL, &dwEscaped, URL_UNESCAPE_INPLACE) == S_OK, "UrlUnescapeW failed unexpectedly\n");
     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)) */
     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));
-    }
 
 }
 
diff --git a/dlls/shlwapi/url.c b/dlls/shlwapi/url.c
index c286fc6..febf6a7 100644
--- a/dlls/shlwapi/url.c
+++ b/dlls/shlwapi/url.c
@@ -1155,13 +1155,15 @@ HRESULT WINAPI UrlUnescapeA(
     TRACE("(%s, %p, %p, 0x%08x)\n", debugstr_a(pszUrl), pszUnescaped,
 	  pcchUnescaped, dwFlags);
 
-    if(!pszUrl || (!pszUnescaped && !(dwFlags & URL_UNESCAPE_INPLACE)) || !pcchUnescaped)
-	return E_INVALIDARG;
+    if (!pszUrl) return E_INVALIDARG;
 
     if(dwFlags & URL_UNESCAPE_INPLACE)
         dst = pszUrl;
     else
+    {
+        if (!pszUnescaped || !pcchUnescaped) return E_INVALIDARG;
         dst = pszUnescaped;
+    }
 
     for(src = pszUrl, needed = 0; *src; src++, needed++) {
         if(dwFlags & URL_DONT_UNESCAPE_EXTRA_INFO &&
@@ -1222,13 +1224,15 @@ HRESULT WINAPI UrlUnescapeW(
     TRACE("(%s, %p, %p, 0x%08x)\n", debugstr_w(pszUrl), pszUnescaped,
 	  pcchUnescaped, dwFlags);
 
-    if(!pszUrl || (!pszUnescaped && !(dwFlags & URL_UNESCAPE_INPLACE))|| !pcchUnescaped)
-	return E_INVALIDARG;
+    if(!pszUrl) return E_INVALIDARG;
 
     if(dwFlags & URL_UNESCAPE_INPLACE)
         dst = pszUrl;
     else
+    {
+        if (!pszUnescaped || !pcchUnescaped) return E_INVALIDARG;
         dst = pszUnescaped;
+    }
 
     for(src = pszUrl, needed = 0; *src; src++, needed++) {
         if(dwFlags & URL_DONT_UNESCAPE_EXTRA_INFO &&




More information about the wine-cvs mailing list