mirror of
https://github.com/KingDuckZ/kamokan.git
synced 2025-02-17 09:35:49 +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:
parent
5f0ea56241
commit
96a349bb8d
4 changed files with 10 additions and 8 deletions
|
@ -167,7 +167,7 @@ int main (int parArgc, char* parArgv[], char* parEnvp[]) {
|
||||||
resp_factory.register_jolly_maker(&make_response<PastieResponse>, RequestMethodType::GET);
|
resp_factory.register_jolly_maker(&make_response<PastieResponse>, RequestMethodType::GET);
|
||||||
|
|
||||||
std::unique_ptr<Response> response = resp_factory.make_response(
|
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()
|
cgi_env->request_method()
|
||||||
);
|
);
|
||||||
if (response)
|
if (response)
|
||||||
|
|
|
@ -110,6 +110,12 @@ namespace cgi {
|
||||||
}
|
}
|
||||||
} //unnamed namespace
|
} //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) :
|
Env::Env(const char* const* parEnvList, const boost::string_view& parBasePath) :
|
||||||
m_cgi_env(cgi_environment_vars(parEnvList)),
|
m_cgi_env(cgi_environment_vars(parEnvList)),
|
||||||
m_skip_path_info(calculate_skip_path_length(m_cgi_env[CGIVars::REQUEST_URI], parBasePath)),
|
m_skip_path_info(calculate_skip_path_length(m_cgi_env[CGIVars::REQUEST_URI], parBasePath)),
|
||||||
|
|
|
@ -82,5 +82,7 @@ namespace tawashi {
|
||||||
RequestMethodType m_request_method_type;
|
RequestMethodType m_request_method_type;
|
||||||
SplitMime m_split_mime;
|
SplitMime m_split_mime;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
boost::string_view drop_arguments (boost::string_view parURI);
|
||||||
} //namespace cgi
|
} //namespace cgi
|
||||||
} //namespace tawashi
|
} //namespace tawashi
|
||||||
|
|
|
@ -41,12 +41,6 @@ namespace tawashi {
|
||||||
return parSettings.as<std::string>("highlight_css");
|
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) {
|
mstch::array pastie_to_numbered_lines (boost::string_view parPastie) {
|
||||||
using boost::string_view;
|
using boost::string_view;
|
||||||
using string_view_iterator = string_view::const_iterator;
|
using string_view_iterator = string_view::const_iterator;
|
||||||
|
@ -132,7 +126,7 @@ namespace tawashi {
|
||||||
}
|
}
|
||||||
|
|
||||||
void PastieResponse::on_mustache_prepare (mstch::map& parContext) {
|
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);
|
boost::optional<std::string> pastie = this->storage().retrieve_pastie(token);
|
||||||
|
|
||||||
if (not is_valid_token(token)) {
|
if (not is_valid_token(token)) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue