diff --git a/dlls/wininet/http.c b/dlls/wininet/http.c index e0bc55d4b41..02f6609bef3 100644 --- a/dlls/wininet/http.c +++ b/dlls/wininet/http.c @@ -4058,6 +4058,9 @@ static DWORD HTTP_HandleRedirect(http_request_t *request, WCHAR *url) urlComponents.dwUrlPathLength = 1; if(!InternetCrackUrlW(url, url_len, 0, &urlComponents)) return INTERNET_GetLastError(); + + if(!urlComponents.dwHostNameLength) + return ERROR_INTERNET_INVALID_URL; } INTERNET_SendCallback(&request->hdr, request->hdr.dwContext, INTERNET_STATUS_REDIRECT, diff --git a/dlls/wininet/tests/http.c b/dlls/wininet/tests/http.c index a3a09800c04..a2890d36268 100644 --- a/dlls/wininet/tests/http.c +++ b/dlls/wininet/tests/http.c @@ -5269,6 +5269,31 @@ static void test_redirect(int port) close_connection(); close_async_handle(req.session, 2); + trace("Test redirect to http URL with no host name...\n"); + + open_socket_request(port, &req); + + SET_EXPECT(INTERNET_STATUS_REQUEST_COMPLETE); + + server_send_string("HTTP/1.1 302 Found\r\n" + "Server: winetest\r\n" + "Location: http:///nohost\r\n" + "Connection: keep-alive\r\n" + "Content-Length: 0\r\n" + "\r\n"); + + WaitForSingleObject(complete_event, INFINITE); + + CHECK_NOTIFIED(INTERNET_STATUS_REQUEST_COMPLETE); + ok(req_error == ERROR_INTERNET_INVALID_URL, "expected ERROR_INTERNET_INVALID_URL, got %u\n", req_error); + + sprintf(expect_url, "http://localhost:%u/socket", port); + test_request_url(req.request, expect_url); + test_status_code(req.request, 302); + + close_connection(); + close_async_handle(req.session, 2); + skip_receive_notification_tests = FALSE; }