bryancall commented on code in PR #12572:
URL: https://github.com/apache/trafficserver/pull/12572#discussion_r2449638655
##########
plugins/experimental/access_control/pattern.cc:
##########
@@ -214,22 +195,13 @@ Pattern::process(const String &subject, StringVector
&result)
bool
Pattern::match(const String &subject)
{
- int matchCount;
AccessControlDebug("matching '%s' to '%s'", _pattern.c_str(),
subject.c_str());
- if (!_re) {
- return false;
- }
-
- matchCount = pcre_exec(_re, _extra, subject.c_str(), subject.length(), 0,
PCRE_NOTEMPTY, nullptr, 0);
- if (matchCount < 0) {
- if (matchCount != PCRE_ERROR_NOMATCH) {
- AccessControlError("matching error %d", matchCount);
- }
+ if (!_re || _re->empty()) {
return false;
}
- return true;
+ return _re->exec(subject);
Review Comment:
NOTEMPTY was removed. Looks like it needs to be added to the flags.
##########
plugins/experimental/access_control/pattern.cc:
##########
@@ -280,21 +245,16 @@ Pattern::capture(const String &subject, StringVector
&result)
bool
Pattern::replace(const String &subject, String &result)
{
- int matchCount;
- int ovector[OVECOUNT];
-
AccessControlDebug("replacing:'%s' in pattern:'%s', subject:'%s'",
_replacement.c_str(), _pattern.c_str(), subject.c_str());
- if (!_re || !_replace) {
+ if (!_re || _re->empty() || !_replace) {
AccessControlError("regular expression not initialized or not configured
to replace");
return false;
}
- matchCount = pcre_exec(_re, nullptr, subject.c_str(), subject.length(), 0,
PCRE_NOTEMPTY, ovector, OVECOUNT);
+ RegexMatches matches(TOKENCOUNT);
+ int matchCount = _re->exec(subject, matches);
Review Comment:
NOTEMPTY was not passed here
##########
plugins/experimental/access_control/pattern.cc:
##########
@@ -214,22 +195,13 @@ Pattern::process(const String &subject, StringVector
&result)
bool
Pattern::match(const String &subject)
{
- int matchCount;
AccessControlDebug("matching '%s' to '%s'", _pattern.c_str(),
subject.c_str());
- if (!_re) {
- return false;
- }
-
- matchCount = pcre_exec(_re, _extra, subject.c_str(), subject.length(), 0,
PCRE_NOTEMPTY, nullptr, 0);
- if (matchCount < 0) {
- if (matchCount != PCRE_ERROR_NOMATCH) {
Review Comment:
This check and error was also removed. Looks like it should be added back
in.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]