Module: wine Branch: master Commit: 9c030d4660780363f5dcda9b33ee6bb4daeef822 URL: http://source.winehq.org/git/wine.git/?a=commit;h=9c030d4660780363f5dcda9b33...
Author: Mikołaj Zalewski mikolaj@zalewski.pl Date: Fri Jun 27 23:08:39 2008 +0200
shlwapi: UrlCanonicalize should strip all the characters <= 32 from the end of the string.
---
dlls/shlwapi/tests/url.c | 16 ++++++++++++++++ dlls/shlwapi/url.c | 2 +- dlls/wininet/tests/internet.c | 6 ++++++ 3 files changed, 23 insertions(+), 1 deletions(-)
diff --git a/dlls/shlwapi/tests/url.c b/dlls/shlwapi/tests/url.c index 37c0111..970b7fb 100644 --- a/dlls/shlwapi/tests/url.c +++ b/dlls/shlwapi/tests/url.c @@ -579,6 +579,7 @@ static void test_UrlCanonicalizeW(void) DWORD dwSize; DWORD urllen; HRESULT hr; + int i;
if (!pUrlCanonicalizeW) { @@ -628,6 +629,21 @@ static void test_UrlCanonicalizeW(void) "got 0x%x with %u and size %u for %u (expected 'S_OK' and size %u)\n", hr, GetLastError(), dwSize, lstrlenW(szReturnUrl), urllen);
+ /* check that the characters 1..32 are chopped from the end of the string */ + for (i = 1; i < 65536; i++) + { + WCHAR szUrl[128]; + BOOL choped; + int pos; + + MultiByteToWideChar(CP_UTF8, 0, "http://www.winehq.org/X", -1, szUrl, 128); + pos = lstrlenW(szUrl) - 1; + szUrl[pos] = i; + urllen = INTERNET_MAX_URL_LENGTH; + pUrlCanonicalizeW(szUrl, szReturnUrl, &urllen, 0); + choped = lstrlenW(szReturnUrl) < lstrlenW(szUrl); + ok(choped == (i <= 32), "Incorrect char chopping for char %d\n", i); + } }
/* ########################### */ diff --git a/dlls/shlwapi/url.c b/dlls/shlwapi/url.c index 16031e8..2efe386 100644 --- a/dlls/shlwapi/url.c +++ b/dlls/shlwapi/url.c @@ -502,7 +502,7 @@ HRESULT WINAPI UrlCanonicalizeW(LPCWSTR pszUrl, LPWSTR pszCanonicalized, debugstr_w(pszUrl), debugstr_w(lpszUrlCpy)); } nLen = lstrlenW(lpszUrlCpy); - while ((nLen > 0) && ((lpszUrlCpy[nLen-1] == '\r')||(lpszUrlCpy[nLen-1] == '\n'))) + while ((nLen > 0) && ((lpszUrlCpy[nLen-1] <= ' '))) lpszUrlCpy[--nLen]=0;
if(dwFlags & (URL_UNESCAPE | URL_FILE_USE_PATHURL)) diff --git a/dlls/wininet/tests/internet.c b/dlls/wininet/tests/internet.c index 9f08b77..0f1e845 100644 --- a/dlls/wininet/tests/internet.c +++ b/dlls/wininet/tests/internet.c @@ -113,6 +113,12 @@ static void test_InternetCanonicalizeUrlA(void) "got %u and %u with size %u for '%s' (%d)\n", res, GetLastError(), dwSize, buffer, lstrlenA(buffer));
+ /* test with trailing space */ + dwSize = 256; + res = InternetCanonicalizeUrlA("http://www.winehq.org/index.php?x= ", buffer, &dwSize, ICU_BROWSER_MODE); + ok(res == 1, "InternetCanonicalizeUrlA failed\n"); + ok(!strcmp(buffer, "http://www.winehq.org/index.php?x="), "Trailing space should have been stripped even in ICU_BROWSER_MODE (%s)\n", buffer); + res = InternetSetOptionA(NULL, 0xdeadbeef, buffer, sizeof(buffer)); ok(!res, "InternetSetOptionA succeeded\n"); ok(GetLastError() == ERROR_INTERNET_INVALID_OPTION,