You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by bc...@apache.org on 2018/08/30 19:07:23 UTC
[trafficserver] branch 8.0.x updated: cachekey: handle empty regex
group captures
This is an automated email from the ASF dual-hosted git repository.
bcall pushed a commit to branch 8.0.x
in repository https://gitbox.apache.org/repos/asf/trafficserver.git
The following commit(s) were added to refs/heads/8.0.x by this push:
new bbf2a86 cachekey: handle empty regex group captures
bbf2a86 is described below
commit bbf2a86655113a5aa718504e687bb12f6209bf8f
Author: Gancho Tenev <ga...@apache.org>
AuthorDate: Sat Aug 11 14:31:12 2018 -0700
cachekey: handle empty regex group captures
(cherry picked from commit 4d5790f796c90db9b8ee245ff179a5a5f66c2608)
---
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);