Fix urlencoding when jumping to unknown ID

This commit is contained in:
Simon Bruder 2024-07-14 13:11:42 +02:00
parent 13ce4d0611
commit 6ad8426e7f
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", "mime",
"printpdf", "printpdf",
"serde", "serde",
"serde_urlencoded",
"serde_variant", "serde_variant",
"sqlx", "sqlx",
"thiserror", "thiserror",

View file

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

View file

@ -75,6 +75,10 @@ async fn jump(
}) { }) {
Ok(web::Redirect::to(format!("/{prefix}/{id}")).see_other()) Ok(web::Redirect::to(format!("/{prefix}/{id}")).see_other())
} else { } 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())
} }
} }