LightCraft: An open-source non-destructive photo editor written by scratch in pure Rust
Merge PR #2406: Remove dot segments when resolving redirect Locations
aiongg4438e2bb6402
diff --cc crates/fetch/src/http.rsindex f99454ede,d5be997ca..974222c2a--- a/crates/fetch/src/http.rs+++ b/crates/fetch/src/http.rs@@@ -622,12 -650,16 +654,22 @@@ mod testsassert!(Url::parse("https://example.com/x?secret=abc\r\nInjected: 1").is_err());}+ #[test]+ fn join_query_only_keeps_file_name() {+ let u = Url::parse("https://a.example/x/y/file?q=1").unwrap();+ assert_eq!(u.join("?page=2").unwrap().path, "/x/y/file?page=2");+ }++ #[test]+ fn join_removes_dot_segments() {+ let base = Url::parse("https://a.example/x/y/file").unwrap();+ for (loc, want) in+ [("../z", "/x/z"), ("./z", "/x/y/z"), ("../../../z", "/z"), ("/a/./b/../c", "/a/c"), ("../z?q=1", "/x/z?q=1"), ("..", "/x/")]+ {+ assert_eq!(base.join(loc).unwrap().path, want, "{loc}");+ }+ }+#[test]fn parses_urls() {let u = Url::parse("https://cdn.example.com/models/sam3/model.safetensors?sig=1#x").unwrap();