Module: wine Branch: master Commit: 9736644ed50f996091afe16243c3fa4a373498a0 URL: http://source.winehq.org/git/wine.git/?a=commit;h=9736644ed50f996091afe16243...
Author: Hans Leidekker hans@codeweavers.com Date: Mon Jun 15 17:32:50 2015 +0200
winhttp: Correctly handle relative redirect paths.
---
dlls/winhttp/request.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-)
diff --git a/dlls/winhttp/request.c b/dlls/winhttp/request.c index 2fee2c3..5aa90e4 100644 --- a/dlls/winhttp/request.c +++ b/dlls/winhttp/request.c @@ -2296,13 +2296,21 @@ static BOOL handle_redirect( request_t *request, DWORD status ) { WCHAR *path, *p;
- len = strlenW( location ) + 1; - if (location[0] != '/') len++; - if (!(p = path = heap_alloc( len * sizeof(WCHAR) ))) goto end; - - if (location[0] != '/') *p++ = '/'; - strcpyW( p, location ); - + if (location[0] == '/') + { + len = strlenW( location ); + if (!(path = heap_alloc( (len + 1) * sizeof(WCHAR) ))) goto end; + strcpyW( path, location ); + } + else + { + if ((p = strrchrW( request->path, '/' ))) *p = 0; + len = strlenW( request->path ) + 1 + strlenW( location ); + if (!(path = heap_alloc( (len + 1) * sizeof(WCHAR) ))) goto end; + strcpyW( path, request->path ); + strcatW( path, slashW ); + strcatW( path, location ); + } heap_free( request->path ); request->path = path;