From 8b04f96297f678b22d5c4374456dba6f79827257 Mon Sep 17 00:00:00 2001 From: Joel Klinghed Date: Thu, 18 Nov 2021 00:20:23 +0100 Subject: site & transport: Make sure to url escape Location header --- src/site.cc | 5 +++-- src/transport.cc | 4 +++- 2 files changed, 6 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/site.cc b/src/site.cc index f8d8116..ebc12a7 100644 --- a/src/site.cc +++ b/src/site.cc @@ -91,8 +91,9 @@ public: if (slash == std::string::npos) { auto trip_id = request->path().substr(1); if (trip_.count(std::string(trip_id))) - return transport->create_redirect(std::string(request->path()) + "/", - false); + return transport->create_redirect( + url::escape(request->path(), url::EscapeFlags::KEEP_SLASH) + "/", + false); } else { auto trip_id = std::string(request->path().substr(1, slash - 1)); auto trip_it = trip_.find(trip_id); diff --git a/src/transport.cc b/src/transport.cc index 8195db7..50f83e4 100644 --- a/src/transport.cc +++ b/src/transport.cc @@ -3,6 +3,7 @@ #include "pathutil.hh" #include "strutil.hh" #include "transport.hh" +#include "urlutil.hh" #include @@ -87,7 +88,8 @@ public: auto clean_path = path::cleanup(request->path()); if (clean_path != request->path()) { - auto response = transport->create_redirect(clean_path, false); + auto response = transport->create_redirect( + url::escape(clean_path, url::EscapeFlags::KEEP_SLASH), false); return response; } -- cgit v1.2.3-70-g09d2