Refactoring: Makes transformations to work with new execute signature

This commit is contained in:
Felipe Zimmerle
2019-02-26 15:39:27 -03:00
parent e3583f342a
commit 12304ea36b
91 changed files with 899 additions and 707 deletions

View File

@@ -30,37 +30,32 @@ namespace modsecurity {
namespace actions {
namespace transformations {
CompressWhitespace::CompressWhitespace(const std::string &action)
: Transformation(action) {
this->action_kind = 1;
}
std::string CompressWhitespace::execute(const std::string &value,
Transaction *transaction) {
std::string a;
void CompressWhitespace::execute(Transaction *t,
ModSecStackString &in,
ModSecStackString &out) {
int inWhiteSpace = 0;
int i = 0;
size_t i = 0;
out.reserve(in.size());
while (i < value.size()) {
if (isspace(value[i])) {
while (i < in.size()) {
if (isspace(in[i])) {
if (inWhiteSpace) {
i++;
continue;
} else {
inWhiteSpace = 1;
a.append(" ", 1);
out.append(" ", 1);
}
} else {
inWhiteSpace = 0;
a.append(&value.at(i), 1);
out.append(&in.at(i), 1);
}
i++;
}
return a;
}
} // namespace transformations
} // namespace actions
} // namespace modsecurity