Commit 8147ccde authored by Haoyang Chen's avatar Haoyang Chen Committed by Alexandre Julliard

winhttp: Handle headers with '\r' line breaks.

parent 19cdc349
......@@ -378,14 +378,17 @@ DWORD add_request_headers( struct request *request, const WCHAR *headers, DWORD
q[0] = '\r';
q[1] = '\n';
}
if (q[0] == '\r' && q[1] == '\n') break;
if (q[0] == '\r') break;
q++;
}
if (!*p) break;
if (*q == '\r')
{
*q = 0;
q += 2; /* jump over \r\n */
if (q[1] == '\n')
q += 2; /* jump over \r\n */
else
q++; /* jump over \r */
}
if ((header = parse_header( p )))
{
......
......@@ -3480,7 +3480,7 @@ static void test_bad_header( int port )
req = WinHttpOpenRequest( con, NULL, NULL, NULL, NULL, NULL, 0 );
ok( req != NULL, "failed to open a request %u\n", GetLastError() );
ret = WinHttpAddRequestHeaders( req, L"Content-Type: text/html\n\r", ~0u, WINHTTP_ADDREQ_FLAG_ADD );
ret = WinHttpAddRequestHeaders( req, L"Content-Type: text/html\n\rContent-Length:6\rCookie:111", ~0u, WINHTTP_ADDREQ_FLAG_ADD );
ok( ret, "failed to add header %u\n", GetLastError() );
index = 0;
......@@ -3492,6 +3492,15 @@ static void test_bad_header( int port )
ok( !lstrcmpW( buffer, L"text/html" ), "got %s\n", wine_dbgstr_w(buffer) );
ok( index == 1, "index = %u\n", index );
index = 0;
buffer[0] = 0;
len = sizeof(buffer);
ret = WinHttpQueryHeaders( req, WINHTTP_QUERY_CUSTOM|WINHTTP_QUERY_FLAG_REQUEST_HEADERS,
L"Cookie", buffer, &len, &index );
ok( ret, "failed to query headers %u\n", GetLastError() );
ok( !lstrcmpW( buffer, L"111" ), "got %s\n", wine_dbgstr_w(buffer) );
ok( index == 1, "index = %u\n", index );
WinHttpCloseHandle( req );
WinHttpCloseHandle( con );
WinHttpCloseHandle( ses );
......
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