@@ -51,12 +51,36 @@ bool Rx::evaluate(Transaction *transaction, RuleWithActions *rule,
51
51
re = m_re;
52
52
}
53
53
54
- std::vector<Utils::SMatchCapture> captures;
55
54
if (re->hasError ()) {
56
55
ms_dbg_a (transaction, 3 , " Error with regular expression: \" " + re->pattern + " \" " );
57
56
return false ;
58
57
}
59
- re->searchOneMatch (input, captures);
58
+
59
+ Utils::RegexResult regex_result;
60
+ std::vector<Utils::SMatchCapture> captures;
61
+
62
+ if (transaction && transaction->m_rules ->m_pcreMatchLimit .m_set ) {
63
+ unsigned long match_limit = transaction->m_rules ->m_pcreMatchLimit .m_value ;
64
+ regex_result = re->searchOneMatch (input, captures, match_limit);
65
+ } else {
66
+ regex_result = re->searchOneMatch (input, captures);
67
+ }
68
+
69
+ // FIXME: DRY regex error reporting. This logic is currently duplicated in other operators.
70
+ if (regex_result != Utils::RegexResult::Ok) {
71
+ transaction->m_variableMscPcreError .set (" 1" , transaction->m_variableOffset );
72
+
73
+ std::string regex_error_str = " OTHER" ;
74
+ if (regex_result == Utils::RegexResult::ErrorMatchLimit) {
75
+ regex_error_str = " MATCH_LIMIT" ;
76
+ transaction->m_variableMscPcreLimitsExceeded .set (" 1" , transaction->m_variableOffset );
77
+ }
78
+
79
+ ms_dbg_a (transaction, 1 , " rx: regex error '" + regex_error_str + " ' for pattern '" + re->pattern + " '" );
80
+
81
+
82
+ return false ;
83
+ }
60
84
61
85
if (rule && rule->hasCaptureAction () && transaction) {
62
86
for (const Utils::SMatchCapture& capture : captures) {
0 commit comments