Skip to content

Commit 820379b

Browse files
committed
Renamos SMatch to RegexMatch
1 parent 8e62341 commit 820379b

File tree

13 files changed

+24
-24
lines changed

13 files changed

+24
-24
lines changed

src/modsecurity.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -228,9 +228,9 @@ int ModSecurity::processContentOffset(const char *content, size_t len,
228228
const unsigned char *buf;
229229
size_t jsonSize;
230230

231-
std::list<regex::SMatch> vars = variables.searchAll(matchString);
232-
std::list<regex::SMatch> ops = operators.searchAll(matchString);
233-
std::list<regex::SMatch> trans = transformations.searchAll(matchString);
231+
std::list<regex::RegexMatch> vars = variables.searchAll(matchString);
232+
std::list<regex::RegexMatch> ops = operators.searchAll(matchString);
233+
std::list<regex::RegexMatch> trans = transformations.searchAll(matchString);
234234

235235
g = yajl_gen_alloc(NULL);
236236
if (g == NULL) {

src/operators/rx.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ bool Rx::init(const std::string &arg, std::string *error) {
3838

3939
bool Rx::evaluate(Transaction *transaction, Rule *rule,
4040
const std::string& input, std::shared_ptr<RuleMessage> ruleMessage) {
41-
std::list<SMatch> matches;
41+
std::list<RegexMatch> matches;
4242
Regex *re;
4343

4444
if (m_param.empty() && !m_string->m_containsMacro) {
@@ -56,7 +56,7 @@ bool Rx::evaluate(Transaction *transaction, Rule *rule,
5656
if (rule && rule->m_containsCaptureAction && transaction) {
5757
int i = 0;
5858
matches.reverse();
59-
for (const SMatch& a : matches) {
59+
for (const RegexMatch& a : matches) {
6060
transaction->m_collections.m_tx_collection->storeOrUpdateFirst(
6161
std::to_string(i), a.str());
6262
ms_dbg_a(transaction, 7, "Added regex subexpression TX." +

src/operators/rx.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727

2828
namespace modsecurity {
29-
using regex::SMatch;
29+
using regex::RegexMatch;
3030
using regex::regex_search;
3131
using regex::Regex;
3232

src/operators/verify_cpf.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ bool VerifyCPF::verify(const char *cpfnumber, int len) {
119119

120120
bool VerifyCPF::evaluate(Transaction *t, Rule *rule,
121121
const std::string& input, std::shared_ptr<RuleMessage> ruleMessage) {
122-
std::list<SMatch> matches;
122+
std::list<RegexMatch> matches;
123123
bool is_cpf = false;
124124
int i;
125125

src/operators/verify_cpf.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626

2727
namespace modsecurity {
28-
using regex::SMatch;
28+
using regex::RegexMatch;
2929
using regex::regex_search;
3030
using regex::Regex;
3131

src/operators/verify_ssn.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ bool VerifySSN::verify(const char *ssnumber, int len) {
110110

111111
bool VerifySSN::evaluate(Transaction *t, Rule *rule,
112112
const std::string& input, std::shared_ptr<RuleMessage> ruleMessage) {
113-
std::list<SMatch> matches;
113+
std::list<RegexMatch> matches;
114114
bool is_ssn = false;
115115
int i;
116116

src/operators/verify_ssn.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626

2727
namespace modsecurity {
28-
using regex::SMatch;
28+
using regex::RegexMatch;
2929
using regex::regex_search;
3030
using regex::Regex;
3131

src/regex/regex.cc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,12 @@ Regex::~Regex() {
6666
}
6767

6868

69-
std::list<SMatch> Regex::searchAll(const std::string& s) const {
69+
std::list<RegexMatch> Regex::searchAll(const std::string& s) const {
7070
const char *subject = s.c_str();
7171
const std::string tmpString = std::string(s.c_str(), s.size());
7272
int ovector[OVECCOUNT];
7373
int rc, i, offset = 0;
74-
std::list<SMatch> retList;
74+
std::list<RegexMatch> retList;
7575

7676
do {
7777
rc = pcre_exec(m_pc, m_pce, subject,
@@ -87,7 +87,7 @@ std::list<SMatch> Regex::searchAll(const std::string& s) const {
8787
}
8888
std::string match = std::string(tmpString, start, len);
8989
offset = start + len;
90-
retList.push_front(SMatch(match, start));
90+
retList.push_front(RegexMatch(match, start));
9191

9292
if (len == 0) {
9393
rc = 0;
@@ -99,13 +99,13 @@ std::list<SMatch> Regex::searchAll(const std::string& s) const {
9999
return retList;
100100
}
101101

102-
int Regex::search(const std::string& s, SMatch *match) const {
102+
int Regex::search(const std::string& s, RegexMatch *match) const {
103103
int ovector[OVECCOUNT];
104104
int ret = pcre_exec(m_pc, m_pce, s.c_str(),
105105
s.size(), 0, 0, ovector, OVECCOUNT) > 0;
106106

107107
if (ret > 0) {
108-
*match = SMatch(
108+
*match = RegexMatch(
109109
std::string(s, ovector[ret-1], ovector[ret] - ovector[ret-1]),
110110
0);
111111
}

src/regex/regex.cc.orig

Whitespace-only changes.

src/regex/regex.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@ namespace regex {
3030

3131
#define OVECCOUNT 30
3232

33-
class SMatch {
33+
class RegexMatch {
3434
public:
35-
SMatch() :
35+
RegexMatch() :
3636
m_match(),
3737
m_offset(0) { }
3838

39-
SMatch(const std::string &match, size_t offset) :
39+
RegexMatch(const std::string &match, size_t offset) :
4040
m_match(match),
4141
m_offset(offset) { }
4242

@@ -58,8 +58,8 @@ class Regex {
5858
Regex(const Regex&) = delete;
5959
Regex& operator=(const Regex&) = delete;
6060

61-
std::list<SMatch> searchAll(const std::string& s) const;
62-
int search(const std::string &s, SMatch *m) const;
61+
std::list<RegexMatch> searchAll(const std::string& s) const;
62+
int search(const std::string &s, RegexMatch *m) const;
6363
int search(const std::string &s) const;
6464

6565
const std::string pattern;
@@ -69,7 +69,7 @@ class Regex {
6969
};
7070

7171

72-
static inline int regex_search(const std::string& s, SMatch *match, const Regex& regex) {
72+
static inline int regex_search(const std::string& s, RegexMatch *match, const Regex& regex) {
7373
return regex.search(s, match);
7474
}
7575

src/regex/regex.h.orig

Whitespace-only changes.

test/regression/regression.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ using modsecurity_test::RegressionTest;
4040
using modsecurity_test::RegressionTestResult;
4141

4242
using modsecurity::regex::regex_search;
43-
using modsecurity::regex::SMatch;
43+
using modsecurity::regex::RegexMatch;
4444
using modsecurity::regex::Regex;
4545

4646
std::string default_test_path = "test-cases/regression";
@@ -207,7 +207,7 @@ void perform_unit_test(ModSecurityTest<RegressionTest> *test,
207207
}
208208

209209
Regex re(t->parser_error);
210-
SMatch match;
210+
RegexMatch match;
211211
std::string s = modsec_rules->getParserError();
212212

213213
if (regex_search(s, &match, re)) {

test/unit/unit_test.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ void replaceAll(std::string *s, const std::string &search,
6060
void json2bin(std::string *str) {
6161
modsecurity::regex::Regex re("\\\\x([a-z0-9A-Z]{2})");
6262
modsecurity::regex::Regex re2("\\\\u([a-z0-9A-Z]{4})");
63-
modsecurity::regex::SMatch match;
63+
modsecurity::regex::RegexMatch match;
6464

6565
while (modsecurity::regex::regex_search(*str, &match, re)) {
6666
unsigned int p;

0 commit comments

Comments
 (0)