mirror of
https://github.com/KingDuckZ/kamokan.git
synced 2025-02-09 09:23:56 +00:00
Add an option to ignore pastie tokens that are too long.
0 disables the limit.
This commit is contained in:
parent
96a349bb8d
commit
f6da79a49d
2 changed files with 6 additions and 2 deletions
|
@ -85,6 +85,7 @@ namespace {
|
|||
parSettings.add_default("log_file", "-");
|
||||
parSettings.add_default("highlight_css", "sh_darkness.css");
|
||||
parSettings.add_default("max_post_size", "1048576");
|
||||
parSettings.add_default("max_token_length", "10");
|
||||
}
|
||||
|
||||
void print_buildtime_info() {
|
||||
|
|
|
@ -64,9 +64,12 @@ namespace tawashi {
|
|||
);
|
||||
}
|
||||
|
||||
bool is_valid_token (const boost::string_view& parToken) {
|
||||
bool is_valid_token (const boost::string_view& parToken, uint32_t parMaxLen) {
|
||||
if (parToken.empty())
|
||||
return false;
|
||||
if (parMaxLen > 0 and parToken.size() > parMaxLen)
|
||||
return false;
|
||||
|
||||
auto it_mark = std::find(parToken.begin(), parToken.end(), '?');
|
||||
if (parToken.begin() == it_mark)
|
||||
return false;
|
||||
|
@ -129,7 +132,7 @@ namespace tawashi {
|
|||
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)) {
|
||||
if (not is_valid_token(token, settings().as<uint32_t>("max_token_length"))) {
|
||||
m_token_invalid = true;
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue