request: GET-params and cookies should not deal with non-printable values
このコミットが含まれているのは:
29
request.cpp
29
request.cpp
@@ -86,7 +86,15 @@ void Request::initCookies(const std::string &cookiestr)
|
||||
|
||||
std::string Request::get(const std::string &key) const
|
||||
{
|
||||
return utils::getKeyOrEmpty(this->getVars, key);
|
||||
std::string value = utils::getKeyOrEmpty(this->getVars, key);
|
||||
/* In general all our expected GET values are printable and, for now, ascii.
|
||||
* If not, it's not a normal request. So just return an empty string then.
|
||||
* Exceptions are probably a bit too much */
|
||||
if(!utils::is_printable_ascii(value))
|
||||
{
|
||||
return "";
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
std::string Request::post(const std::string &key) const
|
||||
@@ -105,23 +113,18 @@ std::string Request::param(const std::string &key) const
|
||||
}
|
||||
std::string Request::cookie(const std::string &key) const
|
||||
{
|
||||
std::string value;
|
||||
for(const Cookie &c : cookies)
|
||||
{
|
||||
if(c.key == key)
|
||||
{
|
||||
return c.value;
|
||||
value = c.value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(utils::is_printable_ascii(value))
|
||||
{
|
||||
return value;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
std::vector<std::string> Request::allGet(const std::string &key)
|
||||
{
|
||||
return utils::getAll(this->getVars, key);
|
||||
}
|
||||
|
||||
std::vector<std::string> Request::allPost(const std::string &key)
|
||||
{
|
||||
return utils::getAll(this->postVars, key);
|
||||
}
|
||||
|
||||
@@ -34,9 +34,6 @@ class Request
|
||||
std::string post(const std::string &key) const;
|
||||
std::string cookie(const std::string &key) const;
|
||||
std::string param(const std::string &key) const;
|
||||
std::vector<std::string> allGet(const std::string &key);
|
||||
std::vector<std::string> allPost(const std::string &key);
|
||||
|
||||
const std::vector<Cookie> &getCookies() const
|
||||
{
|
||||
return this->cookies;
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする