Cosmetic: pleasing cppcheck

This commit is contained in:
Felipe Zimmerle 2021-05-10 16:06:24 -03:00
parent 6fdba42c02
commit 7fccb0d225
2 changed files with 6 additions and 4 deletions

View File

@ -25,7 +25,6 @@
#include "modsecurity/transaction.h" #include "modsecurity/transaction.h"
#include "src/actions/transformations/transformation.h" #include "src/actions/transformations/transformation.h"
#define NBSP 160 // non breaking space char
namespace modsecurity { namespace modsecurity {
namespace actions { namespace actions {
@ -41,12 +40,15 @@ std::string RemoveWhitespace::evaluate(const std::string &val,
std::string value(val); std::string value(val);
int64_t i = 0; int64_t i = 0;
char nonBreakingSpaces = 0xa0; const char nonBreakingSpaces = 0xa0;
const char nonBreakingSpaces2 = 0xc2;
// loop through all the chars // loop through all the chars
while (i < value.size()) { while (i < value.size()) {
// remove whitespaces and non breaking spaces (NBSP) // remove whitespaces and non breaking spaces (NBSP)
if (isspace(value[i]) || (value[i] == nonBreakingSpaces)) { if (std::isspace(static_cast<unsigned char>(value[i]))
|| (value[i] == nonBreakingSpaces)
|| value[i] == nonBreakingSpaces2) {
value.erase(i, 1); value.erase(i, 1);
} else { } else {
/* if the space is not a whitespace char, increment counter /* if the space is not a whitespace char, increment counter

View File

@ -53,7 +53,7 @@ bool Https::write(Transaction *transaction, int parts, std::string *error) {
std::string log = transaction->toJSON(parts); std::string log = transaction->toJSON(parts);
m_http_client.setRequestType("application/json"); m_http_client.setRequestType("application/json");
m_http_client.setRequestBody(log.c_str()); m_http_client.setRequestBody(log);
m_http_client.download(m_audit->m_path1); m_http_client.download(m_audit->m_path1);
return true; return true;
} }