Fix url encoding query and implement FromQueryArgument for Option<T> (#4213)

* Fix url encoding queries

* handle percent encoding hash fragments

* implement fromqueryargument for Option<T>

* fix tests

* fix typo
This commit is contained in:
Evan Almloff authored and GitHub committed 2025-06-02 13:14:53 -05:00
1 parent 662cf0d902
commit 9b16cbf254
13 files changed
+294 -30

No files matched your search

+32 -1
View File
@@ -89,5 +89,36 @@ mod utils {
#[doc(hidden)]
pub mod exports {
pub use urlencoding;
pub use crate::query_sets::*;
pub use percent_encoding;
}
pub(crate) mod query_sets {
//! Url percent encode sets defined [here](https://url.spec.whatwg.org/#percent-encoded-bytes)
use percent_encoding::AsciiSet;
/// The ASCII set that must be escaped in query strings.
pub const QUERY_ASCII_SET: &AsciiSet = &percent_encoding::CONTROLS
.add(b' ')
.add(b'"')
.add(b'#')
.add(b'<')
.add(b'>');
/// The ASCII set that must be escaped in path segments.
pub const PATH_ASCII_SET: &AsciiSet = &QUERY_ASCII_SET
.add(b'?')
.add(b'^')
.add(b'`')
.add(b'{')
.add(b'}');
/// The ASCII set that must be escaped in hash fragments.
pub const FRAGMENT_ASCII_SET: &AsciiSet = &percent_encoding::CONTROLS
.add(b' ')
.add(b'"')
.add(b'<')
.add(b'>')
.add(b'`');
}