Skip to content

Commit fa7973a

Browse files
author
Felipe Zimmerle
committed
Removes a regex optimization added at #1536
1 parent 9e9db08 commit fa7973a

File tree

2 files changed

+3
-15
lines changed

2 files changed

+3
-15
lines changed

src/operators/rx.cc

+3-8
Original file line numberDiff line numberDiff line change
@@ -33,17 +33,14 @@ bool Rx::evaluate(Transaction *transaction, Rule *rule,
3333
const std::string& input, std::shared_ptr<RuleMessage> ruleMessage) {
3434
SMatch match;
3535
std::list<SMatch> matches;
36-
Regex * re = m_re;
36+
Regex *re;
3737

3838
if (m_param.empty()) {
3939
return true;
4040
}
4141

4242
std::string eparam = MacroExpansion::expand(m_param, transaction);
43-
44-
if (eparam != m_param) {
45-
re = new Regex(eparam);
46-
}
43+
re = new Regex(eparam);
4744

4845
matches = re->searchAll(input);
4946
if (rule && rule->getActionsByName("capture").size() > 0 && transaction) {
@@ -65,9 +62,7 @@ bool Rx::evaluate(Transaction *transaction, Rule *rule,
6562
logOffset(ruleMessage, i.m_offset, i.m_length);
6663
}
6764

68-
if (re != m_re) {
69-
delete re;
70-
}
65+
delete re;
7166

7267
if (matches.size() > 0) {
7368
return true;

src/operators/rx.h

-7
Original file line numberDiff line numberDiff line change
@@ -37,19 +37,15 @@ class Rx : public Operator {
3737
/** @ingroup ModSecurity_Operator */
3838
Rx(std::string op, std::string param, bool negation)
3939
: Operator(op, param, negation) {
40-
m_re = new Regex(param);
4140
}
4241
Rx(std::string name, std::string param)
4342
: Operator(name, param) {
44-
m_re = new Regex(param);
4543
}
4644
explicit Rx(std::string param)
4745
: Operator("Rx", param) {
48-
m_re = new Regex(param);
4946
}
5047

5148
~Rx() {
52-
delete m_re;
5349
}
5450
bool evaluate(Transaction *transaction, Rule *rule,
5551
const std::string &input) override {
@@ -62,9 +58,6 @@ class Rx : public Operator {
6258
bool evaluate(Transaction *transaction, Rule *rule,
6359
const std::string& input,
6460
std::shared_ptr<RuleMessage> ruleMessage) override;
65-
66-
private:
67-
Regex *m_re;
6861
};
6962

7063

0 commit comments

Comments
 (0)