mirror of
https://github.com/KingDuckZ/kamokan.git
synced 2025-10-02 15:00:02 +00:00
Fix the bug with the pastie token being invalid.
REQUEST_URI would return "ba"?cpp for example, but the code expects just "ba".
This commit is contained in:
parent
e44611301c
commit
df1afc7616
4 changed files with 24 additions and 1 deletions
|
@ -249,5 +249,11 @@ namespace cgi {
|
||||||
assert(m_skip_path_info <= path.size());
|
assert(m_skip_path_info <= path.size());
|
||||||
return boost::string_ref(path).substr(m_skip_path_info);
|
return boost::string_ref(path).substr(m_skip_path_info);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boost::string_ref Env::path_info_relative() const {
|
||||||
|
const std::string& path = m_cgi_env[CGIVars::PATH_INFO];
|
||||||
|
assert(m_skip_path_info <= path.size());
|
||||||
|
return boost::string_ref(path).substr(m_skip_path_info);
|
||||||
|
}
|
||||||
} //namespace cgi
|
} //namespace cgi
|
||||||
} //namespace tawashi
|
} //namespace tawashi
|
||||||
|
|
|
@ -71,6 +71,7 @@ namespace tawashi {
|
||||||
GetMapType query_string_split() const a_pure;
|
GetMapType query_string_split() const a_pure;
|
||||||
const SplitMime& content_type_split() const a_pure;
|
const SplitMime& content_type_split() const a_pure;
|
||||||
boost::string_ref request_uri_relative() const;
|
boost::string_ref request_uri_relative() const;
|
||||||
|
boost::string_ref path_info_relative() const;
|
||||||
|
|
||||||
std::ostream& print_all (std::ostream& parStream, const char* parNewline) const;
|
std::ostream& print_all (std::ostream& parStream, const char* parNewline) const;
|
||||||
|
|
||||||
|
|
|
@ -75,7 +75,7 @@ namespace tawashi {
|
||||||
}
|
}
|
||||||
|
|
||||||
void PastieResponse::on_mustache_prepare (mstch::map& parContext) {
|
void PastieResponse::on_mustache_prepare (mstch::map& parContext) {
|
||||||
boost::string_ref token = cgi_env().request_uri_relative();
|
boost::string_ref token = cgi_env().path_info_relative();
|
||||||
boost::optional<std::string> pastie = this->storage().retrieve_pastie(token);
|
boost::optional<std::string> pastie = this->storage().retrieve_pastie(token);
|
||||||
|
|
||||||
if (not pastie) {
|
if (not pastie) {
|
||||||
|
|
|
@ -128,6 +128,22 @@ namespace tawashi {
|
||||||
opt_string_list pastie_reply = m_redis->hmget(parToken, "pastie");
|
opt_string_list pastie_reply = m_redis->hmget(parToken, "pastie");
|
||||||
opt_string pastie = (pastie_reply and not pastie_reply->empty() ? (*pastie_reply)[0] : opt_string());
|
opt_string pastie = (pastie_reply and not pastie_reply->empty() ? (*pastie_reply)[0] : opt_string());
|
||||||
|
|
||||||
|
#if defined(SPDLOG_DEBUG_ON)
|
||||||
|
{
|
||||||
|
auto statuslog = spdlog::get("statuslog");
|
||||||
|
if (pastie) {
|
||||||
|
statuslog->debug("Retrieving pastie with token \"{}\" gave a result of size {}",
|
||||||
|
std::string(parToken.data(), parToken.size()),
|
||||||
|
pastie->size()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
statuslog->debug("Retrieving pastie with token \"{}\" gave no results",
|
||||||
|
std::string(parToken.data(), parToken.size())
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
return pastie;
|
return pastie;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue