From f7815fa93ce4bb69fb4b1a3e2d79473b94a647d1 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Mon, 26 May 2008 20:39:41 +0000 Subject: - Bug report #1973352 (http://curl.haxx.se/bug/view.cgi?id=1973352) identified how the HTTP redirect following code didn't properly follow to a new URL if the new url was but a query string such as "Location: ?moo=foo". Test case 1031 was added to verify this fix. --- lib/transfer.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'lib') diff --git a/lib/transfer.c b/lib/transfer.c index 9cae70346..aafec6d4e 100644 --- a/lib/transfer.c +++ b/lib/transfer.c @@ -2044,14 +2044,18 @@ CURLcode Curl_follow(struct SessionHandle *data, if(pathsep) *pathsep=0; - /* we have a relative path to append to the last slash if - there's one available */ - pathsep = strrchr(protsep, '/'); - if(pathsep) - *pathsep=0; + /* we have a relative path to append to the last slash if there's one + available, or if the new URL is just a query string (starts with a + '?') we append the new one at the end of the entire currently worked + out URL */ + if(useurl[0] != '?') { + pathsep = strrchr(protsep, '/'); + if(pathsep) + *pathsep=0; + } - /* Check if there's any slash after the host name, and if so, - remember that position instead */ + /* Check if there's any slash after the host name, and if so, remember + that position instead */ pathsep = strchr(protsep, '/'); if(pathsep) protsep = pathsep+1; @@ -2129,7 +2133,7 @@ CURLcode Curl_follow(struct SessionHandle *data, memcpy(newest, url_clone, urllen); /* check if we need to append a slash */ - if(('/' == useurl[0]) || (protsep && !*protsep)) + if(('/' == useurl[0]) || (protsep && !*protsep) || ('?' == useurl[0])) ; else newest[urllen++]='/'; -- cgit v1.2.3