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

gancho 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 4d5790f  cachekey: handle empty regex group captures
4d5790f is described below

commit 4d5790f796c90db9b8ee245ff179a5a5f66c2608
Author: Gancho Tenev <gan...@apache.org>
AuthorDate: Sat Aug 11 14:31:12 2018 -0700

    cachekey: handle empty regex group captures
---
 plugins/cachekey/pattern.cc | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/plugins/cachekey/pattern.cc b/plugins/cachekey/pattern.cc
index a63fc97..319a4a3 100644
--- a/plugins/cachekey/pattern.cc
+++ b/plugins/cachekey/pattern.cc
@@ -303,6 +303,12 @@ Pattern::replace(const String &subject, String &result)
     int start     = ovector[2 * replIndex];
     int length    = ovector[2 * replIndex + 1] - ovector[2 * replIndex];
 
+    /* Handle the case when no match / a group capture result in an empty 
string */
+    if (start < 0) {
+      start  = 0;
+      length = 0;
+    }
+
     String src(_replacement, _tokenOffset[i], 2);
     String dst(subject, start, length);
 

Reply via email to