mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-08-15 23:55:03 +03:00
Adds support for string_view in Variable
This commit is contained in:
parent
7f1633c1c2
commit
856a84106a
@ -105,6 +105,7 @@ class KeyExclusion {
|
|||||||
public:
|
public:
|
||||||
KeyExclusion() { }
|
KeyExclusion() { }
|
||||||
virtual bool match(const std::string &a) = 0;
|
virtual bool match(const std::string &a) = 0;
|
||||||
|
virtual bool match(const bpstd::string_view &a) = 0;
|
||||||
virtual ~KeyExclusion() { }
|
virtual ~KeyExclusion() { }
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -122,6 +123,10 @@ class KeyExclusionRegex : public KeyExclusion {
|
|||||||
bool match(const std::string &a) override {
|
bool match(const std::string &a) override {
|
||||||
return m_re.searchAll(a).size() > 0;
|
return m_re.searchAll(a).size() > 0;
|
||||||
}
|
}
|
||||||
|
bool match(const bpstd::string_view &a) override {
|
||||||
|
// FIXME: string_view will be a good thing in searchAll.
|
||||||
|
return m_re.searchAll(std::string(a)).size() > 0;
|
||||||
|
}
|
||||||
|
|
||||||
Utils::Regex m_re;
|
Utils::Regex m_re;
|
||||||
};
|
};
|
||||||
@ -141,6 +146,13 @@ class KeyExclusionString : public KeyExclusion {
|
|||||||
return static_cast<char>(toupper(aa)) == static_cast<char>(bb);
|
return static_cast<char>(toupper(aa)) == static_cast<char>(bb);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
bool match(const bpstd::string_view &a) override {
|
||||||
|
return a.size() == m_key.size() && std::equal(a.begin(), a.end(),
|
||||||
|
m_key.begin(),
|
||||||
|
[](char aa, char bb) {
|
||||||
|
return static_cast<char>(toupper(aa)) == static_cast<char>(bb);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
std::string m_key;
|
std::string m_key;
|
||||||
};
|
};
|
||||||
@ -162,7 +174,7 @@ class KeyExclusions : public std::deque<std::unique_ptr<KeyExclusion>> {
|
|||||||
//}
|
//}
|
||||||
};
|
};
|
||||||
|
|
||||||
bool toOmit(std::string a) {
|
bool toOmit(const std::string &a) {
|
||||||
for (auto &z : *this) {
|
for (auto &z : *this) {
|
||||||
if (z->match(a)) {
|
if (z->match(a)) {
|
||||||
return true;
|
return true;
|
||||||
@ -170,6 +182,16 @@ class KeyExclusions : public std::deque<std::unique_ptr<KeyExclusion>> {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool toOmit(const bpstd::string_view &a) {
|
||||||
|
for (auto &z : *this) {
|
||||||
|
if (z->match(a)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user