From a44126539b763bbc02b1f8563a5d4d783e4760b8 Mon Sep 17 00:00:00 2001 From: Amine Khaldi Date: Tue, 28 Feb 2017 15:51:01 +0000 Subject: [PATCH] [WININET] Sync with Wine Staging 2.2. CORE-12823 07e3181 wininet: Fix some spec file entries. 725b55d wininet: Get rid of no longer needed INTERNET_INVALID_PORT_NUMBER in get_server. 0d22e43 wininet: Handle INTERNET_INVALID_PORT_NUMBER in HttpOpenRequest. 8c39694 wininet: Changed usage of UrlEscapeW to fit winapi behavior. b3d12a1 wininet: Canonicalize URL in HttpOpenRequest. 47ff954 wininet: Use return value of sprintf() instead of calling strlen() and simplify code. svn path=/trunk/; revision=74000 --- reactos/dll/win32/wininet/http.c | 21 +++++++++------------ reactos/dll/win32/wininet/internet.c | 10 ++-------- reactos/dll/win32/wininet/wininet.spec | 4 ++-- reactos/media/doc/README.WINE | 2 +- 4 files changed, 14 insertions(+), 23 deletions(-) diff --git a/reactos/dll/win32/wininet/http.c b/reactos/dll/win32/wininet/http.c index 24c6cff1de1..6f7bc2fa1b9 100644 --- a/reactos/dll/win32/wininet/http.c +++ b/reactos/dll/win32/wininet/http.c @@ -250,9 +250,6 @@ server_t *get_server(substr_t name, INTERNET_PORT port, BOOL is_https, BOOL do_c { server_t *iter, *server = NULL; - if(port == INTERNET_INVALID_PORT_NUMBER) - port = INTERNET_DEFAULT_HTTP_PORT; - EnterCriticalSection(&connection_pool_cs); LIST_FOR_EACH_ENTRY(iter, &connection_pool, server_t, entry) { @@ -3388,10 +3385,8 @@ static DWORD HTTP_HttpOpenRequestW(http_session_t *session, port = session->hostPort; if (port == INTERNET_INVALID_PORT_NUMBER) - { port = (session->hdr.dwFlags & INTERNET_FLAG_SECURE) ? INTERNET_DEFAULT_HTTPS_PORT : INTERNET_DEFAULT_HTTP_PORT; - } request->server = get_server(substrz(session->hostName), port, (dwFlags & INTERNET_FLAG_SECURE) != 0, TRUE); if(!request->server) { @@ -3406,13 +3401,14 @@ static DWORD HTTP_HttpOpenRequestW(http_session_t *session, if (lpszObjectName && *lpszObjectName) { HRESULT rc; + WCHAR dummy; - len = 0; - rc = UrlEscapeW(lpszObjectName, NULL, &len, URL_ESCAPE_SPACES_ONLY); + len = 1; + rc = UrlCanonicalizeW(lpszObjectName, &dummy, &len, URL_ESCAPE_SPACES_ONLY); if (rc != E_POINTER) len = strlenW(lpszObjectName)+1; request->path = heap_alloc(len*sizeof(WCHAR)); - rc = UrlEscapeW(lpszObjectName, request->path, &len, + rc = UrlCanonicalizeW(lpszObjectName, request->path, &len, URL_ESCAPE_SPACES_ONLY); if (rc != S_OK) { @@ -4193,12 +4189,13 @@ static DWORD HTTP_HandleRedirect(http_request_t *request, LPCWSTR lpszUrl) request->path = NULL; if (*path) { - DWORD needed = 0; + DWORD needed = 1; HRESULT rc; + WCHAR dummy = 0; - rc = UrlEscapeW(path, NULL, &needed, URL_ESCAPE_SPACES_ONLY); - if (rc == E_POINTER) - needed = strlenW(path)+1; + rc = UrlEscapeW(path, &dummy, &needed, URL_ESCAPE_SPACES_ONLY); + if (rc != E_POINTER) + ERR("Unable to escape string!(%s) (%d)\n",debugstr_w(path),rc); request->path = heap_alloc(needed*sizeof(WCHAR)); rc = UrlEscapeW(path, request->path, &needed, URL_ESCAPE_SPACES_ONLY); diff --git a/reactos/dll/win32/wininet/internet.c b/reactos/dll/win32/wininet/internet.c index 57172542e50..aaef7ed4079 100644 --- a/reactos/dll/win32/wininet/internet.c +++ b/reactos/dll/win32/wininet/internet.c @@ -4098,8 +4098,7 @@ static BOOL calc_url_length(LPURL_COMPONENTSW lpUrlComponents, { char szPort[MAX_WORD_DIGITS+1]; - sprintf(szPort, "%d", lpUrlComponents->nPort); - *lpdwUrlLength += strlen(szPort); + *lpdwUrlLength += sprintf(szPort, "%d", lpUrlComponents->nPort); *lpdwUrlLength += strlen(":"); } @@ -4342,14 +4341,9 @@ BOOL WINAPI InternetCreateUrlW(LPURL_COMPONENTSW lpUrlComponents, DWORD dwFlags, if (!url_uses_default_port(nScheme, lpUrlComponents->nPort)) { - WCHAR szPort[MAX_WORD_DIGITS+1]; - - sprintfW(szPort, fmtW, lpUrlComponents->nPort); *lpszUrl = ':'; lpszUrl++; - dwLen = strlenW(szPort); - memcpy(lpszUrl, szPort, dwLen * sizeof(WCHAR)); - lpszUrl += dwLen; + lpszUrl += sprintfW(lpszUrl, fmtW, lpUrlComponents->nPort); } /* add slash between hostname and path if necessary */ diff --git a/reactos/dll/win32/wininet/wininet.spec b/reactos/dll/win32/wininet/wininet.spec index c4bf4429954..7692c90decf 100644 --- a/reactos/dll/win32/wininet/wininet.spec +++ b/reactos/dll/win32/wininet/wininet.spec @@ -80,10 +80,10 @@ @ stdcall FtpSetCurrentDirectoryW(ptr wstr) @ stdcall GetUrlCacheConfigInfoA(ptr ptr long) @ stdcall GetUrlCacheConfigInfoW(ptr ptr long) -@ stdcall GetUrlCacheEntryInfoA(str ptr long) +@ stdcall GetUrlCacheEntryInfoA(str ptr ptr) @ stdcall GetUrlCacheEntryInfoExA(str ptr ptr str ptr ptr long) @ stdcall GetUrlCacheEntryInfoExW(wstr ptr ptr wstr ptr ptr long) -@ stdcall GetUrlCacheEntryInfoW(wstr ptr long) +@ stdcall GetUrlCacheEntryInfoW(wstr ptr ptr) @ stdcall GetUrlCacheGroupAttributeA(int64 long long ptr ptr ptr) @ stdcall GetUrlCacheGroupAttributeW(int64 long long ptr ptr ptr) @ stub GetUrlCacheHeaderData diff --git a/reactos/media/doc/README.WINE b/reactos/media/doc/README.WINE index d8e5baac3b5..4038b628b52 100644 --- a/reactos/media/doc/README.WINE +++ b/reactos/media/doc/README.WINE @@ -201,7 +201,7 @@ reactos/dll/win32/windowscodecsext # Synced to WineStaging-1.9.11 reactos/dll/win32/winemp3.acm # Synced to WineStaging-2.2 reactos/dll/win32/wing32 # Synced to WineStaging-1.9.11 reactos/dll/win32/winhttp # Synced to WineStaging-1.9.23 -reactos/dll/win32/wininet # Synced to WineStaging-1.9.23 +reactos/dll/win32/wininet # Synced to WineStaging-2.2 reactos/dll/win32/winmm # Forked at Wine-20050628 reactos/dll/win32/winmm/midimap # Forked at Wine-20050628 reactos/dll/win32/winmm/wavemap # Forked at Wine-20050628