From 57825d8ceb21880bcd5e6b05ec7de8df03f0e8b6 Mon Sep 17 00:00:00 2001 From: wawa0210 Date: Fri, 1 Jan 2021 17:49:07 +0800 Subject: [PATCH] fix chart name verification does not meet the specification Signed-off-by: wawa0210 --- pkg/chartutil/create.go | 2 +- pkg/chartutil/create_test.go | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/pkg/chartutil/create.go b/pkg/chartutil/create.go index bdcdc6e97..76a874990 100644 --- a/pkg/chartutil/create.go +++ b/pkg/chartutil/create.go @@ -36,7 +36,7 @@ import ( // This regular expression is probably stricter than it needs to be. We can relax it // somewhat. Newline characters, as well as $, quotes, +, parens, and % are known to be // problematic. -var chartName = regexp.MustCompile("^[a-zA-Z0-9._-]+$") +var chartName = regexp.MustCompile("^[a-z0-9\\-]+$") const ( // ChartfileName is the default Chart file name. diff --git a/pkg/chartutil/create_test.go b/pkg/chartutil/create_test.go index 9a473fc59..852d7dd4e 100644 --- a/pkg/chartutil/create_test.go +++ b/pkg/chartutil/create_test.go @@ -160,8 +160,12 @@ func TestCreate_Overwrite(t *testing.T) { func TestValidateChartName(t *testing.T) { for name, shouldPass := range map[string]bool{ "": false, - "abcdefghijklmnopqrstuvwxyz-_.": true, - "ABCDEFGHIJKLMNOPQRSTUVWXYZ-_.": true, + "abcdefghijklmnopqrstuvwxyz-_.": false, + "ABCDEFGHIJKLMNOPQRSTUVWXYZ-_.": false, + "abcdefghijklmnopqrstuvwxyz": true, + "abcdefghijklmnopqrstuvwxyz_": false, + "abcdefghijklmnopqrstuvwxyz-": true, + "abcdefghijklmnopqrstuvwxyz.": false, "$hello": false, "HellĂ´": false, "he%%o": false,