From 9b43174f3f1b4db98d0ddb67c2b6ba6362ba4112 Mon Sep 17 00:00:00 2001 From: Detlef Riekenberg Date: Fri, 12 Oct 2007 09:36:54 +0200 Subject: [PATCH] wininet: Fix flags and SetLastError for InternetCanonicalizeUrlA/W. --- dlls/wininet/internet.c | 64 +++++++++++++++++++++++------------ dlls/wininet/tests/internet.c | 2 -- 2 files changed, 42 insertions(+), 24 deletions(-) diff --git a/dlls/wininet/internet.c b/dlls/wininet/internet.c index 0edca74598c..4c1472cedd3 100644 --- a/dlls/wininet/internet.c +++ b/dlls/wininet/internet.c @@ -1506,32 +1506,41 @@ BOOL WINAPI InternetCanonicalizeUrlA(LPCSTR lpszUrl, LPSTR lpszBuffer, LPDWORD lpdwBufferLength, DWORD dwFlags) { HRESULT hr; - DWORD dwURLFlags= 0x80000000; /* Don't know what this means */ + DWORD dwURLFlags = URL_WININET_COMPATIBILITY | URL_ESCAPE_UNSAFE; + + TRACE("(%s, %p, %p, 0x%08x) bufferlength: %d\n", debugstr_a(lpszUrl), lpszBuffer, + lpdwBufferLength, lpdwBufferLength ? *lpdwBufferLength : -1, dwFlags); + if(dwFlags & ICU_DECODE) { - dwURLFlags |= URL_UNESCAPE; - dwFlags &= ~ICU_DECODE; + dwURLFlags |= URL_UNESCAPE; + dwFlags &= ~ICU_DECODE; } if(dwFlags & ICU_ESCAPE) { - dwURLFlags |= URL_UNESCAPE; - dwFlags &= ~ICU_ESCAPE; + dwURLFlags |= URL_UNESCAPE; + dwFlags &= ~ICU_ESCAPE; } + if(dwFlags & ICU_BROWSER_MODE) { dwURLFlags |= URL_BROWSER_MODE; dwFlags &= ~ICU_BROWSER_MODE; } - if(dwFlags) - FIXME("Unhandled flags 0x%08x\n", dwFlags); - TRACE("%s %p %p %08x\n", debugstr_a(lpszUrl), lpszBuffer, - lpdwBufferLength, dwURLFlags); - /* Flip this bit to correspond to URL_ESCAPE_UNSAFE */ - dwFlags ^= ICU_NO_ENCODE; + if(dwFlags & ICU_NO_ENCODE) + { + /* Flip this bit to correspond to URL_ESCAPE_UNSAFE */ + dwURLFlags ^= URL_ESCAPE_UNSAFE; + dwFlags &= ~ICU_NO_ENCODE; + } + + if (dwFlags) FIXME("Unhandled flags 0x%08x\n", dwFlags); hr = UrlCanonicalizeA(lpszUrl, lpszBuffer, lpdwBufferLength, dwURLFlags); + if (hr == E_POINTER) SetLastError(ERROR_INSUFFICIENT_BUFFER); + if (hr == E_INVALIDARG) SetLastError(ERROR_INVALID_PARAMETER); return (hr == S_OK) ? TRUE : FALSE; } @@ -1550,36 +1559,47 @@ BOOL WINAPI InternetCanonicalizeUrlW(LPCWSTR lpszUrl, LPWSTR lpszBuffer, LPDWORD lpdwBufferLength, DWORD dwFlags) { HRESULT hr; - DWORD dwURLFlags= 0x80000000; /* Don't know what this means */ + DWORD dwURLFlags = URL_WININET_COMPATIBILITY | URL_ESCAPE_UNSAFE; + + TRACE("(%s, %p, %p, 0x%08x) bufferlength: %d\n", debugstr_w(lpszUrl), lpszBuffer, + lpdwBufferLength, lpdwBufferLength ? *lpdwBufferLength : -1, dwFlags); + if(dwFlags & ICU_DECODE) { - dwURLFlags |= URL_UNESCAPE; - dwFlags &= ~ICU_DECODE; + dwURLFlags |= URL_UNESCAPE; + dwFlags &= ~ICU_DECODE; } if(dwFlags & ICU_ESCAPE) { - dwURLFlags |= URL_UNESCAPE; - dwFlags &= ~ICU_ESCAPE; + dwURLFlags |= URL_UNESCAPE; + dwFlags &= ~ICU_ESCAPE; } + if(dwFlags & ICU_BROWSER_MODE) { dwURLFlags |= URL_BROWSER_MODE; dwFlags &= ~ICU_BROWSER_MODE; } - if(dwFlags) - FIXME("Unhandled flags 0x%08x\n", dwFlags); - TRACE("%s %p %p %08x\n", debugstr_w(lpszUrl), lpszBuffer, - lpdwBufferLength, dwURLFlags); - /* Flip this bit to correspond to URL_ESCAPE_UNSAFE */ - dwFlags ^= ICU_NO_ENCODE; + if(dwFlags & ICU_NO_ENCODE) + { + /* Flip this bit to correspond to URL_ESCAPE_UNSAFE */ + dwURLFlags ^= URL_ESCAPE_UNSAFE; + dwFlags &= ~ICU_NO_ENCODE; + } + + if (dwFlags) FIXME("Unhandled flags 0x%08x\n", dwFlags); hr = UrlCanonicalizeW(lpszUrl, lpszBuffer, lpdwBufferLength, dwURLFlags); + if (hr == E_POINTER) SetLastError(ERROR_INSUFFICIENT_BUFFER); + if (hr == E_INVALIDARG) SetLastError(ERROR_INVALID_PARAMETER); return (hr == S_OK) ? TRUE : FALSE; } +/* #################################################### */ + static INTERNET_STATUS_CALLBACK set_status_callback( LPWININETHANDLEHEADER lpwh, INTERNET_STATUS_CALLBACK callback, BOOL unicode) { diff --git a/dlls/wininet/tests/internet.c b/dlls/wininet/tests/internet.c index 2869cd15fa1..f04c399ec46 100644 --- a/dlls/wininet/tests/internet.c +++ b/dlls/wininet/tests/internet.c @@ -46,7 +46,6 @@ static void test_InternetCanonicalizeUrlA(void) dwSize = 1; /* Acrobat Updater use this size */ SetLastError(0xdeadbeef); res = InternetCanonicalizeUrlA(url, buffer, &dwSize, 0); - todo_wine ok( !res && (GetLastError() == ERROR_INSUFFICIENT_BUFFER) && (dwSize == (urllen+1)), "got %u and %u with size %u for '%s' (%d)\n", res, GetLastError(), dwSize, buffer, lstrlenA(buffer)); @@ -59,7 +58,6 @@ static void test_InternetCanonicalizeUrlA(void) SetLastError(0xdeadbeef); res = InternetCanonicalizeUrlA(url, buffer, &dwSize, 0); /* dwSize is nr. of needed bytes with the terminating '\0' */ - todo_wine ok( !res && (GetLastError() == ERROR_INSUFFICIENT_BUFFER) && (dwSize == (urllen+1)), "got %u and %u with size %u for '%s' (%d)\n", res, GetLastError(), dwSize, buffer, lstrlenA(buffer));