[core] Share paths: judge dot segments on the NFKC form, so look-alike dots and spaces inside names pass; refuse slash look-alikes and broken escapes like %+f

This commit is contained in:
2026-11-07 19:40:49 +01:00
parent 17f26f94a3
commit cbb3e41ca7
2 changed files with 65 additions and 7 deletions
+27
View File
@@ -355,6 +355,20 @@ fn paths_under_the_prefix_are_within() {
("/a", "/a/%C3%A9t%C3%A9.jpg"),
("/a", "/a/%e2%9c%93"),
("/a", "/a/a%20b"),
// QC fix round 3: ordinary names with look-alike dots or spaces inside.
("/a", "/a/Wait%E2%80%A6.pdf"),
("/a", "/a/%E3%80%80photo"),
("/a", "/a/my%C2%A0file.pdf"),
("/a", "/a/dokumenty/p%C5%99ehled"),
("/a", "/a/my%20file.pdf"),
("/a", "/a/a+b"),
("/a", "/a/caf%C3%A9"),
("/a", "/a/e%CC%81"),
("/a", "/a/%E2%80%93"),
("/a", "/a/%E6%97%85%E8%A1%8C"),
("/a", "/a/.well-known/x"),
("/a", "/a/%C2%BD.txt"),
("/a", "/a/x%3Fy"),
] {
assert!(path_within(prefix, path), "{prefix} should cover {path}");
}
@@ -431,6 +445,19 @@ fn no_path_trick_escapes_the_prefix() {
("/a", "/a/%e3%80%80/b"),
("/a", "/a/%zz/b"),
("/a", "/a/%e2%9c"),
// QC fix round 3: a segment that is only an ellipsis or a look-alike space, slash
// look-alikes, and a broken escape that from_str_radix would take.
("/a", "/a/%E2%80%A6/b"),
("/a", "/a/%E2%80%A6"),
("/a", "/a/%E3%80%80/b"),
("/a", "/a/%C2%A0%C2%A0/b"),
("/a", "/a/..%e2%88%95b"),
("/a", "/a/..%e2%81%84b"),
("/a", "/a/..%e2%a7%b8b"),
("/a", "/a/x%e2%88%95y"),
("/a", "/a/x%e2%81%84y"),
("/a", "/a/%+f/b"),
("/a", "/a/%-1/b"),
];
for (prefix, path) in cases {
assert!(