servo / rust-url

URL parser for Rust
https://docs.rs/url/
Apache License 2.0
1.31k stars 325 forks source link

`form_urlencoded::ByteSerialize` does NOT conform to the URL standard #927

Open kaffarell opened 5 months ago

kaffarell commented 5 months ago

As mentioned in the URL Standard here the percent-encode of a bytestream is defined as follows:

To percent-encode after encoding, given an encoding encoding, scalar value string input, a percentEncodeSet, and an optional boolean spaceAsPlus (default false):

On step 5.3.1 the spaceAsPlus parameter is used:

If spaceAsPlus is true and byte is 0x20 (SP), then append U+002B (+) to output and continue.

The issue here is that: 1) The url crate does NOT have a spaceAsPlus parameter. 2) The url crate encodes the SPACE character as a '+' per default, although the default behavior should actually be '%20'.

Another issue: #888

valenting commented 5 months ago

Thanks for the bug request. I'm happy to review a PR for this.