Commit 3098e3c3 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

wininet: Address string should never be converted to UNICODE in status notifications.

parent 2544999e
......@@ -115,10 +115,19 @@ static void WINAPI internet_status_callback(HINTERNET internet, DWORD_PTR contex
report_progress(protocol, BINDSTATUS_FINDINGRESOURCE, (LPWSTR)status_info);
break;
case INTERNET_STATUS_CONNECTING_TO_SERVER:
TRACE("%p INTERNET_STATUS_CONNECTING_TO_SERVER\n", protocol);
report_progress(protocol, BINDSTATUS_CONNECTING, (LPWSTR)status_info);
case INTERNET_STATUS_CONNECTING_TO_SERVER: {
WCHAR *info;
TRACE("%p INTERNET_STATUS_CONNECTING_TO_SERVER %s\n", protocol, (const char*)status_info);
info = heap_strdupAtoW(status_info);
if(!info)
return;
report_progress(protocol, BINDSTATUS_CONNECTING, info);
heap_free(info);
break;
}
case INTERNET_STATUS_SENDING_REQUEST:
TRACE("%p INTERNET_STATUS_SENDING_REQUEST\n", protocol);
......
......@@ -159,6 +159,7 @@ static const test_data_t test_data[] = {
};
static INTERNET_STATUS_CALLBACK (WINAPI *pInternetSetStatusCallbackA)(HINTERNET ,INTERNET_STATUS_CALLBACK);
static INTERNET_STATUS_CALLBACK (WINAPI *pInternetSetStatusCallbackW)(HINTERNET ,INTERNET_STATUS_CALLBACK);
static BOOL (WINAPI *pInternetGetSecurityInfoByURLA)(LPSTR,PCCERT_CHAIN_CONTEXT*,DWORD*);
static int strcmp_wa(LPCWSTR strw, const char *stra)
......@@ -321,12 +322,16 @@ static VOID WINAPI callback(
trace("%04x:Callback %p 0x%lx INTERNET_STATUS_CONNECTING_TO_SERVER \"%s\" %d\n",
GetCurrentThreadId(), hInternet, dwContext,
(LPCSTR)lpvStatusInformation,dwStatusInformationLength);
ok(dwStatusInformationLength == strlen(lpvStatusInformation)+1, "unexpected size %u\n",
dwStatusInformationLength);
*(LPSTR)lpvStatusInformation = '\0';
break;
case INTERNET_STATUS_CONNECTED_TO_SERVER:
trace("%04x:Callback %p 0x%lx INTERNET_STATUS_CONNECTED_TO_SERVER \"%s\" %d\n",
GetCurrentThreadId(), hInternet, dwContext,
(LPCSTR)lpvStatusInformation,dwStatusInformationLength);
ok(dwStatusInformationLength == strlen(lpvStatusInformation)+1, "unexpected size %u\n",
dwStatusInformationLength);
*(LPSTR)lpvStatusInformation = '\0';
break;
case INTERNET_STATUS_SENDING_REQUEST:
......@@ -3595,19 +3600,27 @@ static void WINAPI cb(HINTERNET handle, DWORD_PTR context, DWORD status, LPVOID
trace("%p 0x%08lx %u %p 0x%08x\n", handle, context, status, info, size);
if (status == INTERNET_STATUS_REQUEST_COMPLETE)
{
switch(status) {
case INTERNET_STATUS_REQUEST_COMPLETE:
trace("request handle: 0x%08lx\n", result->dwResult);
ctx->req = (HINTERNET)result->dwResult;
SetEvent(ctx->event);
}
if (status == INTERNET_STATUS_HANDLE_CLOSING)
{
break;
case INTERNET_STATUS_HANDLE_CLOSING: {
DWORD type = INTERNET_HANDLE_TYPE_CONNECT_HTTP, size = sizeof(type);
if (InternetQueryOption(handle, INTERNET_OPTION_HANDLE_TYPE, &type, &size))
ok(type != INTERNET_HANDLE_TYPE_CONNECT_HTTP, "unexpected callback\n");
SetEvent(ctx->event);
break;
}
case INTERNET_STATUS_NAME_RESOLVED:
case INTERNET_STATUS_CONNECTING_TO_SERVER:
case INTERNET_STATUS_CONNECTED_TO_SERVER: {
char *str = info;
ok(str[0] && str[1], "Got string: %s\n", str);
ok(size == strlen(str)+1, "unexpected size %u\n", size);
}
}
}
......@@ -3619,6 +3632,10 @@ static void test_open_url_async(void)
struct context ctx;
ULONG type;
/* Collect all existing persistent connections */
ret = InternetSetOptionA(NULL, INTERNET_OPTION_SETTINGS_CHANGED, NULL, 0);
ok(ret, "InternetSetOption(INTERNET_OPTION_END_BROWSER_SESSION) failed: %u\n", GetLastError());
ctx.req = NULL;
ctx.event = CreateEvent(NULL, TRUE, FALSE, "Z:_home_hans_jaman-installer.exe_ev1");
......@@ -3636,7 +3653,7 @@ static void test_open_url_async(void)
ok(!ret, "InternetSetOptionA failed\n");
ok(error == ERROR_INTERNET_OPTION_NOT_SETTABLE, "got %u expected ERROR_INTERNET_OPTION_NOT_SETTABLE\n", error);
pInternetSetStatusCallbackA(ses, cb);
pInternetSetStatusCallbackW(ses, cb);
ResetEvent(ctx.event);
req = InternetOpenUrl(ses, "http://test.winehq.org", NULL, 0, 0, (DWORD_PTR)&ctx);
......@@ -4123,6 +4140,7 @@ START_TEST(http)
}
pInternetSetStatusCallbackA = (void*)GetProcAddress(hdll, "InternetSetStatusCallbackA");
pInternetSetStatusCallbackW = (void*)GetProcAddress(hdll, "InternetSetStatusCallbackW");
pInternetGetSecurityInfoByURLA = (void*)GetProcAddress(hdll, "InternetGetSecurityInfoByURLA");
init_status_tests();
......
......@@ -298,62 +298,48 @@ static const char *debugstr_status_info(DWORD status, void *info)
}
}
VOID INTERNET_SendCallback(object_header_t *hdr, DWORD_PTR dwContext,
DWORD dwInternetStatus, LPVOID lpvStatusInfo,
DWORD dwStatusInfoLength)
void INTERNET_SendCallback(object_header_t *hdr, DWORD_PTR context, DWORD status, void *info, DWORD info_len)
{
LPVOID lpvNewInfo = NULL;
void *new_info = info;
if( !hdr->lpfnStatusCB )
return;
/* the IE5 version of wininet does not
send callbacks if dwContext is zero */
if( !dwContext )
if(!context)
return;
lpvNewInfo = lpvStatusInfo;
if(hdr->dwInternalFlags & INET_CALLBACKW) {
switch(dwInternetStatus) {
case INTERNET_STATUS_NAME_RESOLVED:
case INTERNET_STATUS_CONNECTING_TO_SERVER:
case INTERNET_STATUS_CONNECTED_TO_SERVER:
lpvNewInfo = heap_strdupAtoW(lpvStatusInfo);
dwStatusInfoLength *= sizeof(WCHAR);
break;
case INTERNET_STATUS_RESOLVING_NAME:
case INTERNET_STATUS_REDIRECT:
lpvNewInfo = heap_strdupW(lpvStatusInfo);
break;
}
}else {
switch(dwInternetStatus)
{
case INTERNET_STATUS_NAME_RESOLVED:
case INTERNET_STATUS_CONNECTING_TO_SERVER:
case INTERNET_STATUS_CONNECTED_TO_SERVER:
lpvNewInfo = heap_alloc(strlen(lpvStatusInfo) + 1);
if (lpvNewInfo) strcpy(lpvNewInfo, lpvStatusInfo);
switch(status) {
case INTERNET_STATUS_NAME_RESOLVED:
case INTERNET_STATUS_CONNECTING_TO_SERVER:
case INTERNET_STATUS_CONNECTED_TO_SERVER:
new_info = heap_alloc(info_len);
if(new_info)
memcpy(new_info, info, info_len);
break;
case INTERNET_STATUS_RESOLVING_NAME:
case INTERNET_STATUS_REDIRECT:
if(hdr->dwInternalFlags & INET_CALLBACKW) {
new_info = heap_strdupW(info);
break;
case INTERNET_STATUS_RESOLVING_NAME:
case INTERNET_STATUS_REDIRECT:
lpvNewInfo = heap_strdupWtoA(lpvStatusInfo);
dwStatusInfoLength /= sizeof(WCHAR);
}else {
new_info = heap_strdupWtoA(info);
info_len = strlen(new_info)+1;
break;
}
}
TRACE(" callback(%p) (%p (%p), %08lx, %d (%s), %s, %d)\n",
hdr->lpfnStatusCB, hdr->hInternet, hdr, dwContext, dwInternetStatus, get_callback_name(dwInternetStatus),
debugstr_status_info(dwInternetStatus, lpvNewInfo), dwStatusInfoLength);
hdr->lpfnStatusCB, hdr->hInternet, hdr, context, status, get_callback_name(status),
debugstr_status_info(status, new_info), info_len);
hdr->lpfnStatusCB(hdr->hInternet, dwContext, dwInternetStatus,
lpvNewInfo, dwStatusInfoLength);
hdr->lpfnStatusCB(hdr->hInternet, context, status, new_info, info_len);
TRACE(" end callback().\n");
if(lpvNewInfo != lpvStatusInfo)
heap_free(lpvNewInfo);
if(new_info != info)
heap_free(new_info);
}
typedef struct {
......
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