mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-08-15 23:55:03 +03:00
Fix pcre_exec matched string
This commit is contained in:
parent
0285c944f9
commit
c800214e6d
@ -30,8 +30,7 @@ bool Rx::evaluate(Assay *assay, const std::string& input) {
|
|||||||
SMatch match;
|
SMatch match;
|
||||||
|
|
||||||
if (regex_search(input, &match, *m_re) && match.size() >= 1) {
|
if (regex_search(input, &match, *m_re) && match.size() >= 1) {
|
||||||
std::cout << "wheee" << std::endl;
|
this->matched.push_back(match.match);
|
||||||
// this->matched.push_back(match.match);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,8 +48,15 @@ Regex::Regex(const std::string& pattern_)
|
|||||||
int regex_search(const std::string& s, SMatch *match,
|
int regex_search(const std::string& s, SMatch *match,
|
||||||
const Regex& regex) {
|
const Regex& regex) {
|
||||||
int ovector[OVECCOUNT];
|
int ovector[OVECCOUNT];
|
||||||
return pcre_exec(regex.m_pc, regex.m_pce, s.c_str(),
|
int ret = pcre_exec(regex.m_pc, regex.m_pce, s.c_str(),
|
||||||
s.size(), 0, 0, ovector, OVECCOUNT) > 0;
|
s.size(), 0, 0, ovector, OVECCOUNT) > 0;
|
||||||
|
|
||||||
|
if (ret > 0) {
|
||||||
|
match->match = std::string(s, ovector[2], ovector[3] - ovector[2]);
|
||||||
|
match->size_ = ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int regex_search(const std::string& s, const Regex& regex) {
|
int regex_search(const std::string& s, const Regex& regex) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user