Copilot commented on code in PR #12219:
URL: https://github.com/apache/trafficserver/pull/12219#discussion_r2072061669


##########
src/iocore/net/SSLSNIConfig.cc:
##########
@@ -231,43 +228,28 @@ SNIConfigParams::get(std::string_view servername, 
in_port_t dest_incoming_port)
   }
 
   // Check for wildcard matches
-  int ovector[OVECSIZE];
+  RegexMatches matches;
 
   for (auto const &retval : sni_action_list) {
     if (element != nullptr && element->rank < retval.rank) {
       break;
     }
 
-    int length = servername.length();
-    if (retval.match == nullptr && length == 0) {
+    if (retval.match.empty() && servername.length() == 0) {
       return {&retval.actions, {}};
-    } else if (auto offset = pcre_exec(retval.match.get(), nullptr, 
servername.data(), length, 0, 0, ovector, OVECSIZE);
-               offset >= 0) {
+    } else if (retval.match.exec(servername, matches) >= 0) {
       if (!is_port_in_the_ranges(retval.inbound_port_ranges, 
dest_incoming_port)) {
         continue;
       }
-      if (offset == 1) {
-        // first pair identify the portion of the subject string matched by 
the entire pattern
-        if (ovector[0] == 0 && ovector[1] == length) {
-          // full match
-          return {&retval.actions, {}};
-        } else {
-          continue;
-        }
-      }
-      // If contains groups
-      if (offset == 0) {
-        // reset to max if too many.
-        offset = OVECSIZE / 3;
+      if (matches.size() == 1) {
+        // full match
+        return {&retval.actions, {}};
       }
 
       ActionItem::Context::CapturedGroupViewVec groups;
-      groups.reserve(offset);
-      for (int strnum = 1; strnum < offset; strnum++) {
-        const std::size_t start  = ovector[2 * strnum];
-        const std::size_t length = ovector[2 * strnum + 1] - start;
-
-        groups.emplace_back(servername.data() + start, length);
+      groups.reserve(matches.size());
+      for (int count = 0; count < matches.size(); count++) {

Review Comment:
   [nitpick] If the full match (at index 0) should be excluded from the 
captured groups—as in the previous logic—consider starting the iteration at 
index 1 rather than 0.
   ```suggestion
         for (int count = 1; count < matches.size(); count++) {
   ```



-- 
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: github-unsubscr...@trafficserver.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to