1
0
Fork 0
mirror of https://github.com/KingDuckZ/kamokan.git synced 2024-11-23 00:33:44 +00:00

Drop ?blabla before calling factory.make_response().

This fixes the problem with error.cgi?reason=... being
mistaken for a pastie.
This commit is contained in:
King_DuckZ 2017-06-08 21:57:09 +01:00
parent 5f0ea56241
commit 96a349bb8d
4 changed files with 10 additions and 8 deletions

View file

@ -167,7 +167,7 @@ int main (int parArgc, char* parArgv[], char* parEnvp[]) {
resp_factory.register_jolly_maker(&make_response<PastieResponse>, RequestMethodType::GET);
std::unique_ptr<Response> response = resp_factory.make_response(
cgi_env->request_uri_relative(),
tawashi::cgi::drop_arguments(cgi_env->request_uri_relative()),
cgi_env->request_method()
);
if (response)

View file

@ -110,6 +110,12 @@ namespace cgi {
}
} //unnamed namespace
boost::string_view drop_arguments (boost::string_view parURI) {
auto it_found = std::find(parURI.begin(), parURI.end(), '?');
assert(it_found - parURI.begin() <= parURI.size());
return parURI.substr(0, it_found - parURI.begin());
}
Env::Env(const char* const* parEnvList, const boost::string_view& parBasePath) :
m_cgi_env(cgi_environment_vars(parEnvList)),
m_skip_path_info(calculate_skip_path_length(m_cgi_env[CGIVars::REQUEST_URI], parBasePath)),

View file

@ -82,5 +82,7 @@ namespace tawashi {
RequestMethodType m_request_method_type;
SplitMime m_split_mime;
};
boost::string_view drop_arguments (boost::string_view parURI);
} //namespace cgi
} //namespace tawashi

View file

@ -41,12 +41,6 @@ namespace tawashi {
return parSettings.as<std::string>("highlight_css");
}
boost::string_view get_pastie_name (boost::string_view parRequest) {
auto it_found = std::find(parRequest.begin(), parRequest.end(), '?');
assert(it_found - parRequest.begin() <= parRequest.size());
return parRequest.substr(0, it_found - parRequest.begin());
}
mstch::array pastie_to_numbered_lines (boost::string_view parPastie) {
using boost::string_view;
using string_view_iterator = string_view::const_iterator;
@ -132,7 +126,7 @@ namespace tawashi {
}
void PastieResponse::on_mustache_prepare (mstch::map& parContext) {
boost::string_view token = get_pastie_name(cgi_env().request_uri_relative());
boost::string_view token = cgi::drop_arguments(cgi_env().request_uri_relative());
boost::optional<std::string> pastie = this->storage().retrieve_pastie(token);
if (not is_valid_token(token)) {