10 comments

[ 2.3 ms ] story [ 31.1 ms ] thread
This is really excellent, it’s the main thing that curb the ruby binding I work on never felt right. We used ruby URL for the parsing and as it turns out it’s slightly less forgiving than libcurls internal parser.
The blog post mentions WHATWG URL spec and RFC 3986 - what is libcurl's URL parser implementing, what is its goal?

By the way, parsing of URLs is a large-ish task; it'd be nice to have URL API in a separate library, which libcurl depends on, and which can be used without libcurl.

I've touched on a few URL parsing issues lately. Valid UTF-8 code points depending on TLD and determining the user level of the host e.g. 3rd level for co.uk seem to require gathering a bunch of disparate sources and making a best guess.

I agree it's a large task, and it'll be interesting to see the scope of libcurl's API for it.

Serious question: what's the value of using this over https://uriparser.github.io/ ?
Perhaps, if you're using a lot of curl and want to make sure your program parses URLs the same way curl does.
It will be consistent with the logic used by the codebase that actually fetches the URL (curl), so it won't leave gaps between the expected behavior and actual behavior the way two disjoint implementations would.
(comment deleted)
From the article:

> By offering applications access to libcurl's own URL parser, we hope to tighten a problematic vulnerable area for applications where the URL parser library would believe one thing and libcurl another. This could and has sometimes lead to security problems. (See for example Exploiting URL Parser in Trending Programming Languages! by Orange Tsai)

I'd say because tons of projects use curl anyway, whereas I for example have never heard of this uriparser.