From 8795977da9894a3a2e20448548c36cdafc949002 Mon Sep 17 00:00:00 2001 From: King_DuckZ Date: Wed, 7 Jun 2017 00:49:44 +0100 Subject: [PATCH] Extract pastie's token manually from the request uri. --- src/tawashi/pastie_response.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/tawashi/pastie_response.cpp b/src/tawashi/pastie_response.cpp index ce62f24..b3e5e02 100644 --- a/src/tawashi/pastie_response.cpp +++ b/src/tawashi/pastie_response.cpp @@ -24,6 +24,7 @@ #include #include #include +#include namespace tawashi { namespace { @@ -34,6 +35,15 @@ namespace tawashi { return parSettings.as("highlight_css"); } + boost::string_view get_pastie_name (boost::string_view parRequest) { + using boost::string_view; + + auto it_found = std::find(parRequest.begin(), parRequest.end(), '?'); + if (parRequest.end() == it_found) + return parRequest.substr(0, it_found - parRequest.begin()); + else + return parRequest; + } } //unnamed namespace PastieResponse::PastieResponse ( @@ -76,7 +86,7 @@ namespace tawashi { } void PastieResponse::on_mustache_prepare (mstch::map& parContext) { - boost::string_view token = cgi_env().path_info_relative(); + boost::string_view token = get_pastie_name(cgi_env().request_uri_relative()); boost::optional pastie = this->storage().retrieve_pastie(token); if (not pastie) {