Closed karatakis closed 1 month ago
should should be the consistency? Should it be URL safe all over or should it use []?
I used https://www.urlencoder.org/ to determine the correct URL, and it returned %2Fendpoint%3Fbank_account_ids%5B%5D%3Did1%26bank_account_ids%5B%5D%3Did2
Maybe it is a different issue (the code editor or terminal decodes the URL safely)
It is a bug in the depending crate.
Code that replicates the issue.
let mut url = Url::parse("https://example.com/?id[]=1&id[]=2").unwrap();
let pairs = vec![
("id[]", "3"),
("id[]", "4"),
];
url.query_pairs_mut().extend_pairs(
pairs.iter().map(|&(k, v)| { (&k[..], &v[..]) })
);|
// Not working as intended
assert_eq!("https://example.com/?id[]=1&id[]=2&id[]=3&id[]=4", url.as_str());
Apart from the test mocking, there are no other problems. With real servers, we have no issue because they decode the URL. (Tested with ExpressJS and tokio Hyper)
Does not have any real-world impact apart from appearance. Closing until further notice that this bug impacts someone.
Prerequisites
Describe the bug
When URL encoding the following link
/endpoint?bank_account_ids[]=id1&bank_account_ids[]=id2
we receive
/endpoint?bank_account_ids[]=id1&bank_account_ids%5B%5D=id2
Notice the
[]
for first id it is[]
but for the next it is%5B%5D
Steps to reproduce
Expected behavior
Either all
[]
are encoded to%5B%5D
or all%5B%5D
to[]
Actual behavior
Notice the
[]
for first id it is[]
but for the next it is%5B%5D
Environment information: