From b9849153f06459294af6c09d0d3f09daa9885349 Mon Sep 17 00:00:00 2001 From: neri Date: Tue, 22 Nov 2022 21:11:59 +0100 Subject: [PATCH] fix url decoding in /uploaded endpoint --- src/upload.rs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/upload.rs b/src/upload.rs index 1d9813c..de2910c 100644 --- a/src/upload.rs +++ b/src/upload.rs @@ -140,15 +140,17 @@ fn get_file_url(req: &HttpRequest, id: &str, name: Option<&str>) -> String { } } -pub async fn uploaded(req: HttpRequest) -> Result { - let id = req.match_info().query("id"); - let name = req.match_info().get("name"); +pub async fn uploaded( + req: HttpRequest, + path: web::Path<(String, Option)>, +) -> Result { + let (id, name) = path.into_inner(); let upload_html = if name.is_some() { UPLOAD_SHORT_HTML - .replace("{link}", &get_file_url(&req, id, name)) - .replace("{shortlink}", &get_file_url(&req, id, None)) + .replace("{link}", &get_file_url(&req, &id, name.as_deref())) + .replace("{shortlink}", &get_file_url(&req, &id, None)) } else { - UPLOAD_HTML.replace("{link}", &get_file_url(&req, id, name)) + UPLOAD_HTML.replace("{link}", &get_file_url(&req, &id, name.as_deref())) }; Ok(HttpResponse::Ok() .content_type("text/html")