cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: URL containing spaces/white space

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Mon, 17 Aug 2009 11:56:40 +0200 (CEST)

On Mon, 17 Aug 2009, centrio_at_gmail.com wrote:

> and if my url contains white spaces at the end, will it cause any connection
> failures??

No.

> Or curl will ignore the whitespaces at the end and do it correctly.

Do what correctly? By passing something that isn't legal in a URL to libcurl's
option that wants a URL, you're out on thin ice. I would argue that libcurl
could do one of two things:

1) strictly parse the URL and reject it since a URL (well URI to be strict)
    can't contain spaces

2) only insist that the URL is enough conformant so that libcurl can use it,
    accepting all possible violations you can do while still making it mostly
    look like a URL to libcurl.

libcurl has the (2) attitude, as it has the added benefit that you can use it
to test servers etc with requests that aren't otherwise possible if libcurl
would've only accepted legal URLs. That benefit could be seen as a problem,
given your point of view.

I believe that some apps would like libcurl to do (1) and I've seen that
people expect that behavior at times, and if someone would implement that as
an optional feature I think I'd approve of it.

> I found out that the white spaces at the beginning of a URL create problem
> in identifying the protocol.

Yes, and spaces in the middle of the URL will cause other problems that at
times will be caught by libcurl or will be passed to the server which might be
surprised to get spaces where they aren't allowede.

> But when I tried putting white spaces at the end of URL, they succeded
> sometimes and sometimes failed.

If that fails, it's because the server dislikes them. You also didn't mention
what protocol you tried this with, so it's a bit hard to guess exactly what
happened.

-- 
  / daniel.haxx.se
Received on 2009-08-17