@@ -51,12 +51,36 @@ bool Rx::evaluate(Transaction *transaction, RuleWithActions *rule,
5151 re = m_re;
5252 }
5353
54- std::vector<Utils::SMatchCapture> captures;
5554 if (re->hasError ()) {
5655 ms_dbg_a (transaction, 3 , " Error with regular expression: \" " + re->pattern + " \" " );
5756 return false ;
5857 }
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+ }
6084
6185 if (rule && rule->hasCaptureAction () && transaction) {
6286 for (const Utils::SMatchCapture& capture : captures) {
0 commit comments