[core] Share paths and errors: refuse overlong UTF-8, %u, look-alike dots and slashes and trimmed dot segments; never repeat URL credentials in an error

This commit is contained in:
2026-11-07 18:53:42 +01:00
parent 4448527b16
commit 2b66729f1b
5 changed files with 105 additions and 13 deletions
+14
View File
@@ -238,3 +238,17 @@ fn params_carry_suggestions() {
assert_eq!(e.params()["suggestion"], "http://10.0.0.2:3000");
assert_eq!(e.params()["url"], "http://10.0.0.2:3000/app");
}
#[test]
fn a_password_in_an_upstream_url_is_never_repeated() {
let errs = errors_for(
"hostname = \"app.test\"\nupstreams = [\"http://admin:hunter2@10.0.0.2:3000\", \"ftp://u:hunter2@x\", \"http://admin:hunter2@10.0.0.2:3000\"]\n",
);
assert!(!errs.is_empty());
for e in &errs {
let all = format!("{e} {:?} {:?}", e.params(), e.field());
assert!(!all.contains("hunter2"), "{all}");
}
let e = errs.iter().find(|e| e.code() == "host.upstream.credentials").unwrap();
assert_eq!(e.params()["url"], "http://\u{2026}@10.0.0.2:3000");
}