curl-users
endless loop on redirect (with patch)
From: Ingo Wilken <iw_at_WWW.Ecce-Terram.DE>
Date: Thu, 10 May 2001 13:21:38 +0200 (MET DST)
Date: Thu, 10 May 2001 13:21:38 +0200 (MET DST)
Hi,
I was testing an application based on curl 7.7.3 on some URLs, and it ran
into an endless loop while while trying to fetch http://www.lifeline.de.
The reason was a redirect:
---- HTTP/1.1 301 Moved Permanently Date: Thu, 10 May 2001 11:15:10 GMT Server: Apache/1.3.9 (Unix) Location: /cda/page/center/0,1347,,FF.html Transfer-Encoding: chunked Content-Type: text/html ---- Note the two spaces after the Location: field (allowed according to RFC 2068 section 4.2). Unfortunately, curl copied the second space into the new URL... This patch fixes the problem: ---- diff -cwr curl-7.7.3-orig/lib/transfer.c curl-7.7.3/lib/transfer.c *** curl-7.7.3-orig/lib/transfer.c Thu May 3 12:45:39 2001 --- curl-7.7.3/lib/transfer.c Thu May 10 13:05:39 2001 *************** *** 517,523 **** char *start=p; char backup; ! start += 10; /* pass "Location: " */ ptr = start; /* start scanning here */ /* scan through the string to find the end */ while(*ptr && !isspace((int)*ptr)) --- 517,526 ---- char *start=p; char backup; ! start += 9; /* pass "Location:" */ ! /* skip spaces and tabs */ ! while( *start==' ' || *start=='\t' ) ! start++; ptr = start; /* start scanning here */ /* scan through the string to find the end */ while(*ptr && !isspace((int)*ptr)) ---- Regards, Ingo -- ECCE TERRAM Internet Services GmbH Ingo Wilken Edewechter Landstr. 42 delta_at_ecce-terram.de 26131 Oldenburg ++49 (0)441/500-12-0Received on 2001-05-10