Fix urlencoding when jumping to unknown ID

This commit is contained in:
Simon Bruder 2024-07-14 13:11:42 +02:00
parent d4b0290bd4
commit 35c287e082
Signed by: simon
GPG key ID: 347FF8699CDA0776
3 changed files with 7 additions and 1 deletions

1
Cargo.lock generated
View file

@ -1200,6 +1200,7 @@ dependencies = [
"mime",
"printpdf",
"serde",
"serde_urlencoded",
"serde_variant",
"sqlx",
"thiserror",

View file

@ -25,6 +25,7 @@ maud = { version = "0.26.0", features = ["actix-web"] }
mime = "0.3.17"
printpdf = "0.7.0"
serde = { version = "1.0.203", features = ["serde_derive"] }
serde_urlencoded = "0.7.1"
serde_variant = "0.1.3"
sqlx = { version = "0.7.4", features = ["runtime-tokio", "postgres", "uuid", "time"] }
thiserror = "1.0.61"

View file

@ -75,6 +75,10 @@ async fn jump(
}) {
Ok(web::Redirect::to(format!("/{prefix}/{id}")).see_other())
} else {
Ok(web::Redirect::to(format!("/items/add?name={id}")).see_other())
Ok(web::Redirect::to(format!(
"/items/add?{}",
serde_urlencoded::to_string([("name", &id)])?
))
.see_other())
}
}