mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-09-29 19:24:29 +03:00
Fix several minor issues on the seclang grammar
This commit is contained in:
@@ -59,6 +59,14 @@ void Pm::postOrderTraversal(acmp_btree_node_t *node) {
|
||||
node = NULL;
|
||||
}
|
||||
|
||||
void Pm::replaceAll(std::string& str, const std::string& from, const std::string& to) {
|
||||
size_t start_pos = 0;
|
||||
while((start_pos = str.find(from, start_pos)) != std::string::npos) {
|
||||
size_t end_pos = start_pos + from.length();
|
||||
str.replace(start_pos, end_pos, to);
|
||||
start_pos += to.length();
|
||||
}
|
||||
}
|
||||
|
||||
bool Pm::evaluate(Assay *assay, const std::string &input) {
|
||||
int rc = 0;
|
||||
@@ -79,6 +87,8 @@ bool Pm::evaluate(Assay *assay, const std::string &input) {
|
||||
bool Pm::init(const char **error) {
|
||||
std::vector<std::string> vec;
|
||||
|
||||
replaceAll(param, "\\", "\\\\");
|
||||
|
||||
char *content = parse_pm_content(param.c_str(), param.length(), error);
|
||||
if (content == NULL) {
|
||||
return false;
|
||||
|
@@ -35,7 +35,7 @@ class Pm : public Operator {
|
||||
m_p = acmp_create(0);
|
||||
}
|
||||
~Pm();
|
||||
|
||||
void replaceAll(std::string& str, const std::string& from, const std::string& to);
|
||||
bool evaluate(Assay *assay, const std::string &input);
|
||||
|
||||
virtual bool init(const char **error);
|
||||
|
@@ -24,10 +24,12 @@ namespace ModSecurity {
|
||||
namespace operators {
|
||||
|
||||
|
||||
|
||||
bool Rx::evaluate(Assay *assay, const std::string& input) {
|
||||
SMatch match;
|
||||
|
||||
if (regex_search(input, &match, m_re) && match.size() >= 1) {
|
||||
std::string i = input;
|
||||
if (regex_search(i, &match, m_re) && match.size() >= 1) {
|
||||
this->matched.push_back(match.match);
|
||||
return true;
|
||||
}
|
||||
|
Reference in New Issue
Block a user