From 3c8e6d7151e12d14141aa41367a1f28e1464bc07 Mon Sep 17 00:00:00 2001 From: "Stuart P. Bentley" Date: Sat, 10 Oct 2020 15:47:38 -0700 Subject: [PATCH] Group regex within anchoring This ensures that anchoring will apply to the entire anchored expression, eg. a pattern like `foo|bar` will only match the strings "foo" and "bar" (`^(?:foo|bar)$`), instead of matching any string that begins with "foo" or ends with "bar" (`^foo|bar$`). --- api/resmap/reswrangler.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/resmap/reswrangler.go b/api/resmap/reswrangler.go index 618c64f8d..ce83767e6 100644 --- a/api/resmap/reswrangler.go +++ b/api/resmap/reswrangler.go @@ -514,7 +514,7 @@ func anchorRegex(pattern string) string { if pattern == "" { return pattern } - return "^" + pattern + "$" + return "^(?:" + pattern + ")$" } // Select returns a list of resources that