wininet: Canonicalize URL in HttpOpenRequest.

Signed-off-by: Daniel Lehman <dlehman@esri.com>
Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Daniel Lehman 2016-10-26 12:17:17 -07:00 committed by Alexandre Julliard
parent 4eac6e84ba
commit b3d12a16ce
2 changed files with 23 additions and 3 deletions

View File

@ -3401,13 +3401,14 @@ static DWORD HTTP_HttpOpenRequestW(http_session_t *session,
if (lpszObjectName && *lpszObjectName) { if (lpszObjectName && *lpszObjectName) {
HRESULT rc; HRESULT rc;
WCHAR dummy;
len = 0; len = 1;
rc = UrlEscapeW(lpszObjectName, NULL, &len, URL_ESCAPE_SPACES_ONLY); rc = UrlCanonicalizeW(lpszObjectName, &dummy, &len, URL_ESCAPE_SPACES_ONLY);
if (rc != E_POINTER) if (rc != E_POINTER)
len = strlenW(lpszObjectName)+1; len = strlenW(lpszObjectName)+1;
request->path = heap_alloc(len*sizeof(WCHAR)); request->path = heap_alloc(len*sizeof(WCHAR));
rc = UrlEscapeW(lpszObjectName, request->path, &len, rc = UrlCanonicalizeW(lpszObjectName, request->path, &len,
URL_ESCAPE_SPACES_ONLY); URL_ESCAPE_SPACES_ONLY);
if (rc != S_OK) if (rc != S_OK)
{ {

View File

@ -2402,6 +2402,10 @@ static DWORD CALLBACK server_thread(LPVOID param)
send(c, okmsg, sizeof(okmsg)-1, 0); send(c, okmsg, sizeof(okmsg)-1, 0);
send(c, buffer, strlen(buffer), 0); send(c, buffer, strlen(buffer), 0);
} }
if (strstr(buffer, "GET /test_remove_dot_segments"))
{
send(c, okmsg, sizeof(okmsg)-1, 0);
}
shutdown(c, 2); shutdown(c, 2);
closesocket(c); closesocket(c);
c = -1; c = -1;
@ -4851,6 +4855,20 @@ static void test_long_url(int port)
close_request(&req); close_request(&req);
} }
static void test_remove_dot_segments(int port)
{
test_request_t req;
BOOL ret;
open_simple_request(&req, "localhost", port, NULL, "/A/../B/./C/../../test_remove_dot_segments");
ret = HttpSendRequestA(req.request, NULL, 0, NULL, 0);
ok(ret, "HttpSendRequest failed: %u\n", GetLastError());
test_status_code(req.request, 200);
close_request(&req);
}
static void test_http_connection(void) static void test_http_connection(void)
{ {
struct server_info si; struct server_info si;
@ -4902,6 +4920,7 @@ static void test_http_connection(void)
test_async_read(si.port); test_async_read(si.port);
test_http_read(si.port); test_http_read(si.port);
test_long_url(si.port); test_long_url(si.port);
test_remove_dot_segments(si.port);
/* send the basic request again to shutdown the server thread */ /* send the basic request again to shutdown the server thread */
test_basic_request(si.port, "GET", "/quit"); test_basic_request(si.port, "GET", "/quit");