Skip to content

Commit 3334d2a

Browse files
committed
Regex search in collection data case insensitive fix
1 parent 145f2f3 commit 3334d2a

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

src/collection/backend/in_memory-per_process.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ void InMemoryPerProcess::resolveRegularExpression(const std::string& var,
134134
//std::string name = std::string(var, var.find(":") + 2,
135135
// var.size() - var.find(":") - 3);
136136
//size_t keySize = col.size();
137-
Utils::Regex r(var);
137+
Utils::Regex r(var, PCRE_CASELESS);
138138

139139
for (const auto& x : *this) {
140140
//if (x.first.size() <= keySize + 1) {

src/utils/regex.cc

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,18 @@ Regex::Regex(const std::string& pattern_)
4949
m_pce = pcre_study(m_pc, pcre_study_opt, &errptr);
5050
}
5151

52+
Regex::Regex(const std::string& pattern_, int flags)
53+
: pattern(pattern_.empty() ? ".*" : pattern_){
54+
const char *errptr = NULL;
55+
int erroffset;
56+
57+
flags |= (PCRE_DOTALL|PCRE_MULTILINE);
58+
59+
m_pc = pcre_compile(pattern.c_str(), flags,
60+
&errptr, &erroffset, NULL);
61+
62+
m_pce = pcre_study(m_pc, pcre_study_opt, &errptr);
63+
}
5264

5365
Regex::~Regex() {
5466
if (m_pc != NULL) {

src/utils/regex.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
namespace modsecurity {
2828
namespace Utils {
2929

30-
#define OVECCOUNT 30
30+
#define OVECCOUNT 50
3131

3232
class SMatch {
3333
public:
@@ -51,6 +51,7 @@ class SMatch {
5151
class Regex {
5252
public:
5353
explicit Regex(const std::string& pattern_);
54+
explicit Regex(const std::string& pattern_, int flags);
5455
~Regex();
5556

5657
// m_pc and m_pce can't be easily copied

0 commit comments

Comments
 (0)