Cosmetics: fix some cppcheck complains to please QA

This commit is contained in:
Felipe Zimmerle
2020-04-29 10:19:49 -03:00
parent 310cbf899b
commit 9b40a045bb
26 changed files with 244 additions and 77 deletions

View File

@@ -24,6 +24,7 @@
#include "modsecurity/rule.h"
#include "modsecurity/rule_message.h"
#ifdef MSC_DOCUMENTATION
/**
* Description: Assigns a tag (category) to a rule or a chain.
*
@@ -44,7 +45,7 @@
*
*
*/
#endif
namespace modsecurity {
namespace actions {

View File

@@ -41,11 +41,12 @@ std::string RemoveWhitespace::evaluate(const std::string &val,
std::string value(val);
int64_t i = 0;
char nonBreakingSpaces = 0xa0;
// loop through all the chars
while (i < value.size()) {
// remove whitespaces and non breaking spaces (NBSP)
if (isspace(value[i]) || (value[i] == NBSP)) {
if (isspace(value[i]) || (value[i] == nonBreakingSpaces)) {
value.erase(i, 1);
} else {
/* if the space is not a whitespace char, increment counter

View File

@@ -32,15 +32,25 @@ namespace transformations {
std::string *Trim::ltrim(std::string *s) {
s->erase(s->begin(), std::find_if(s->begin(), s->end(),
std::not1(std::ptr_fun<int, int>(std::isspace))));
s->erase(
s->begin(),
std::find_if(s->begin(), s->end(), [](unsigned char c) {
return !std::isspace(c);
})
);
return s;
}
std::string *Trim::rtrim(std::string *s) {
s->erase(std::find_if(s->rbegin(), s->rend(),
std::not1(std::ptr_fun<int, int>(std::isspace))).base(), s->end());
s->erase(
std::find_if(s->rbegin(), s->rend(), [](unsigned char c) {
return !std::isspace(c);
}).base(),
s->end()
);
return s;
}

View File

@@ -39,7 +39,7 @@ UrlDecode::UrlDecode(const std::string &action)
std::string UrlDecode::evaluate(const std::string &value,
Transaction *transaction) {
unsigned char *val = NULL;
unsigned char *val(NULL);
int invalid_count = 0;
int changed;