servo / rust-url

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

percent ("%) character must be percent-encoded as "%25" #822

Closed santhosh-tekuri closed 1 year ago

santhosh-tekuri commented 1 year ago

Describe the bug A clear and concise description of what the bug is. Include code snippets if possible. From https://www.rfc-editor.org/rfc/rfc3986#section-2.4:

Because the percent ("%") character serves as the indicator for
percent-encoded octets, it must be percent-encoded as "%25" for that
octet to be used as data within a URI.

below is test case to produce bug:

let mut url = Url::parse("http://example.com/test").unwrap();
url.set_fragment(Some("ab cd%ef"));
assert_eq!(url.as_str(), "http://example.com/test#ab%20cd%25ef");

output:

thread 'util::tests::test_equals' panicked at 'assertion failed: `(left == right)`
  left: `"http://example.com/test#ab%20cd%ef"`,
 right: `"http://example.com/test#ab%20cd%25ef"`', src/util.rs:305:9
valenting commented 1 year ago
  • [x] Note that this crate implements the URL Standard not RFC 1738 or RFC 3986

Describe the bug A clear and concise description of what the bug is. Include code snippets if possible. From https://www.rfc-editor.org/rfc/rfc3986#section-2.4:

I am a bit confused why you checked the box if you're referencing the RFC it explicitly says it doesn't implement. 🙂 Anyways, here's this test case in the reference URL parser