This is an automated email from the ASF dual-hosted git repository.

mochen pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git


The following commit(s) were added to refs/heads/master by this push:
     new 68110d5ae3 traffic_cache: use single regex in url_matcher port (#12585)
68110d5ae3 is described below

commit 68110d5ae32455b00f081c6cff72073d96b91d8d
Author: Mo Chen <[email protected]>
AuthorDate: Fri Oct 24 12:40:18 2025 -0500

    traffic_cache: use single regex in url_matcher port (#12585)
    
    This match is a single regex match.  DFA is meant for multiple regex 
matching.  Since Regex defaults to unanchored mode, add required anchors to the 
patterns.
---
 src/traffic_cache_tool/CacheDefs.h | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/traffic_cache_tool/CacheDefs.h 
b/src/traffic_cache_tool/CacheDefs.h
index db76bb99f0..1d9a8c6464 100644
--- a/src/traffic_cache_tool/CacheDefs.h
+++ b/src/traffic_cache_tool/CacheDefs.h
@@ -307,7 +307,7 @@ struct url_matcher {
         std::cout << "Check your regular expression" << std::endl;
       }
 
-      if (!port.compile(R"([0-9]+$)")) {
+      if (!port.compile(R"(^[0-9]+$)")) {
         std::cout << "Check your regular expression" << std::endl;
         return;
       }
@@ -320,7 +320,7 @@ struct url_matcher {
       std::cout << "Check your regular expression" << std::endl;
       return;
     }
-    if (!port.compile(R"([0-9]+$)")) {
+    if (!port.compile(R"(^[0-9]+$)")) {
       std::cout << "Check your regular expression" << std::endl;
       return;
     }
@@ -336,12 +336,12 @@ struct url_matcher {
   uint8_t
   portmatch(const char *hostname, int length) const
   {
-    return port.match({hostname, size_t(length)}) ? 1 : 0;
+    return port.exec({hostname, static_cast<size_t>(length)}) ? 1 : 0;
   }
 
 private:
-  DFA port;
-  DFA regex;
+  Regex port;
+  DFA   regex;
 };
 
 using swoc::Errata;

Reply via email to