mozilla/rust — pull request #3069 by dbp (2012-08-01 03:35:01+00:00)
Title: std::net::url - adding encoding/decoding of components and forms (from erickt/rust-uri) and more compliant parsing

This includes both a merge of erickt's url / form encoding/decoding code into net::url and a bunch of work to make the parsing a lot more robust. It (obviously) builds off of the rough draft that I wrote a couple weeks ago. In particular, it now actually follows the RFC in terms of what characters are allowed where, as far as I am aware. It also produces error messages when invalid urls are encountered (they could probably use improvement).

In terms of reading the diff, the first couple hundred lines are erickt's encoding/decoding code, with the only changes being some naming and type updates (mainly using @~strs instead of @strs). The core of the new code is in the get_* functions - which do the parsing of various components; only get_authority has significant logic in it (which is primarily caused by the use of ':' in the spec - it can separate a user from password, parts of an ipv6 host, or a host from a port). And of course `from_str` was rewritten to use this new code; it serves as a guide of the order things happen in (and the names follow the convention in the RFC).

Finally, there are a bunch of new tests - all the ones from erickt's repo for encoding/decoding, and some to test individual component parsing and some more full url tests.

brson made some changes to the type of query a couple days ago to make it sendable - presumably those changes should also be made to the encoding/decoding functions for forms, but I'm not sure how it would be best to handle it (straight vectors/tuples, or something else?), and I wanted to have erickt's code mostly intact for this pull request (to try to keep the new code limited).

(I have run the local tests and the lint check from make check - I'm running the full make check now, but it takes forever on my slow machine and since this code is not used anywhere as far as I know, I doubt there would be anything elsewhere that could cause a failure; if there is, I will obviously update this).