cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: CR/LF in URL

From: Ralph Mitchell <ralphmitchell_at_gmail.com>
Date: Mon, 10 Apr 2006 07:18:39 -0500

This has bitten me before. I usually use tr to strip the CR:

   curl -l ftp://ftp.gtk.org/pub/gtk/perl/ | tr -d '\r' | while read FILENAME
   do
     curl -sSO ftp://ftp.gtk.org/pub/gtk/perl/$FILENAME
   done

I think that's right - I don't have my work system handy to check it.

Ralph Mitchell

On 4/10/06, Jeff Pohlmeyer <yetanothergeek_at_gmail.com> wrote:
> Using bash, I tried to do something like this:
> ---
> curl -l ftp://ftp.gtk.org/pub/gtk/perl/ | while read FILENAME
> do
> curl -sSO ftp://ftp.gtk.org/pub/gtk/perl/$FILENAME
> done
> ---
> And I get this:
>
> curl: (3) URL using bad/illegal format or missing URL
> curl: (3) URL using bad/illegal format or missing URL
> curl: (3) URL using bad/illegal format or missing URL
> etc...
>
> The problem is that the the ftp LIST response is in CR/LF format,
> and the bash 'read' strips the LF, but not the CR.
>
> I suppose that's my mistake, but it sure took me a while to
> figure out what I was doing wrong! Is there any reason why
> curl shouldn't strip the CR if it finds one?
>
>
> This patch may be a bit too simplistic,
> but it seems to solve the problem:
>
> --- main.c.OLD 2006-04-10 06:35:53.133455408 -0500
> +++ main.c.NEW 2006-04-10 06:35:43.724885728 -0500
> @@ -3793,6 +3793,7 @@
>
> /* size of uploaded file: */
> curl_easy_setopt(curl, CURLOPT_INFILESIZE_LARGE, uploadfilesize);
> + if ( strchr(url, 0xd) ) *strchr(url, 0xd)=0x0;
> curl_easy_setopt(curl, CURLOPT_URL, url); /* what to fetch */
> curl_easy_setopt(curl, CURLOPT_PROXY, config->proxy); /*
> proxy to use */
> curl_easy_setopt(curl, CURLOPT_HEADER, config->conf&CONF_HEADER);
>
>
> - Jeff
>
>
Received on 2006-04-10