Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
kaffarell opened this issue Apr 30, 2024 · 1 comment · May be fixed by #928
Open

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

kaffarell opened this issue Apr 30, 2024 · 1 comment · May be fixed by #928

Comments

@kaffarell
Copy link

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

@kaffarell kaffarell changed the title form_urlencoded::ByteSerialize does NOT conform to the URL Standard form_urlencoded::ByteSerialize does NOT conform to the URL standard Apr 30, 2024
@valenting
Copy link
Collaborator

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

kaffarell added a commit to kaffarell/rust-url that referenced this issue Apr 30, 2024
Previously the space character was exclusively encoded to '+'. This is
wrong, as the URL Standard [0] specifies that the default is '%20'.
Another function has been introduced as well, which replicates the old
behavior and converts spaces to '+'.
Notice that this breaks the default behavior and could lead to bugs.

[0]: https://url.spec.whatwg.org/#string-percent-encode-after-encoding

Fixes: servo#927
Fixes: servo#888

Signed-off-by: Gabriel Goller <g.goller@proxmox.com>
@kaffarell kaffarell linked a pull request Apr 30, 2024 that will close this issue
kaffarell added a commit to kaffarell/rust-url that referenced this issue Apr 30, 2024
Previously the space character was exclusively encoded to '+'. This is
wrong, as the URL Standard [0] specifies that the default is '%20'.
Another function has been introduced as well, which replicates the old
behavior and converts spaces to '+'.
Notice that this breaks the default behavior and could lead to bugs.

[0]: https://url.spec.whatwg.org/#string-percent-encode-after-encoding

Fixes: servo#927
Fixes: servo#888

Signed-off-by: Gabriel Goller <g.goller@proxmox.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants