From 6ad8426e7f995b61e2651f3117b811703d5677e8 Mon Sep 17 00:00:00 2001 From: Simon Bruder Date: Sun, 14 Jul 2024 13:11:42 +0200 Subject: [PATCH] Fix urlencoding when jumping to unknown ID --- Cargo.lock | 1 + Cargo.toml | 1 + src/frontend/mod.rs | 6 +++++- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index fb4d7e1..c2b14f0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1200,6 +1200,7 @@ dependencies = [ "mime", "printpdf", "serde", + "serde_urlencoded", "serde_variant", "sqlx", "thiserror", diff --git a/Cargo.toml b/Cargo.toml index 94f280b..2ce0a23 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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" diff --git a/src/frontend/mod.rs b/src/frontend/mod.rs index 301ca37..9abd150 100644 --- a/src/frontend/mod.rs +++ b/src/frontend/mod.rs @@ -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()) } }