v0.34.0_4
This commit is contained in:
1 parent
f20c8da718
commit
5910e6e901
21 files changed
+377
-51
No files matched your search
@@ -255,4 +255,21 @@ mod tests {
|
||||
assert!(routing_path(path).is_err(), "{path}");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn borrowed_route_path_matches_original_validator_for_safe_and_unsafe_targets() {
|
||||
use std::borrow::Cow;
|
||||
for value in ["/", "/a/b", "/static/app.js", "/café", "/admin/%61", "/a//b", "/%2e%2e/a", "/..", "/a;secret", "/x%2Fy", "/%00", "/a b", "/bad%", "/a\\b", "not-absolute"] {
|
||||
let original = routing_path(value);
|
||||
let borrowed = routing_path_view(value);
|
||||
assert_eq!(original.is_ok(), borrowed.is_ok(), "{value}");
|
||||
if let (Ok(normalized), Ok(view)) = (original, borrowed) {
|
||||
assert_eq!(normalized, view.as_ref(), "{value}");
|
||||
}
|
||||
}
|
||||
assert!(matches!(routing_path_view("/foo/bar").unwrap(), Cow::Borrowed(_)));
|
||||
assert!(matches!(routing_path_view("/foo//bar").unwrap(), Cow::Owned(_)));
|
||||
assert!(matches!(routing_path_view("/%61").unwrap(), Cow::Owned(_)));
|
||||
assert!(routing_path_view(&format!("/{}", "x".repeat(8192))).is_err());
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user