mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-08-14 13:56:01 +03:00
added remove_comments_char to address issue #971
This commit is contained in:
parent
8da49842d8
commit
a5a21ea192
@ -37,14 +37,28 @@ RemoveCommentsChar::RemoveCommentsChar(std::string action)
|
|||||||
|
|
||||||
std::string RemoveCommentsChar::evaluate(std::string value,
|
std::string RemoveCommentsChar::evaluate(std::string value,
|
||||||
Transaction *transaction) {
|
Transaction *transaction) {
|
||||||
/**
|
int64_t i;
|
||||||
* @todo Implement the transformation RemoveCommentsChar
|
|
||||||
*/
|
i = 0;
|
||||||
if (transaction) {
|
while (i < value.size()) {
|
||||||
#ifndef NO_LOGS
|
if (value.at(i) == '/' && (i+1 < value.size()) && value.at(i+1) == '*') {
|
||||||
transaction->debug(4, "Transformation RemoveCommentsChar " \
|
value.erase(i, 2);
|
||||||
"is not implemented yet.");
|
} else if (value.at(i) == '*' && (i+1 < value.size()) && value.at(i+1) == '/') {
|
||||||
#endif
|
value.erase(i, 2);
|
||||||
|
} else if (value.at(i) == '<' && (i+1 < value.size()) && value.at(i+1) == '!' &&
|
||||||
|
(i+2 < value.size()) && value.at(i+2) == '-' && (i+3 < value.size()) &&
|
||||||
|
value.at(i+3) == '-') {
|
||||||
|
value.erase(i, 4);
|
||||||
|
} else if (value.at(i) == '-' && (i+1 < value.size()) && value.at(i+1) == '-' &&
|
||||||
|
(i+2 < value.size()) && value.at(i+2) == '>') {
|
||||||
|
value.erase(i, 3);
|
||||||
|
} else if (value.at(i) == '-' && (i+1 < value.size()) && value.at(i+1) == '-') {
|
||||||
|
value.erase(i, 2);
|
||||||
|
} else if (value.at(i) == '#') {
|
||||||
|
value.erase(i, 1);
|
||||||
|
} else {
|
||||||
|
i++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user