diff --git a/components/gitpod-cli/cmd/preview.go b/components/gitpod-cli/cmd/preview.go index 27c6026ae69391..32dcc9d9d15a76 100644 --- a/components/gitpod-cli/cmd/preview.go +++ b/components/gitpod-cli/cmd/preview.go @@ -19,7 +19,7 @@ import ( "github.com/gitpod-io/gitpod/gitpod-cli/pkg/theialib" ) -var regexLocalhost = regexp.MustCompile(`((^(localhost|127\.0\.0\.1))|(https?://(localhost|127\.0\.0\.1)))(:[0-9]+)?`) +var regexLocalhost = regexp.MustCompile(`((^(localhost|127\.0\.0\.1))|(https?:\/\/(localhost|127\.0\.0\.1)))(:[0-9]+)?`) var previewCmdOpts struct { External bool diff --git a/components/ws-daemon/pkg/quota/size.go b/components/ws-daemon/pkg/quota/size.go index d66895d9acd187..8216eda8035d5e 100644 --- a/components/ws-daemon/pkg/quota/size.go +++ b/components/ws-daemon/pkg/quota/size.go @@ -31,7 +31,7 @@ const ( ) var ( - sizeRegexp = regexp.MustCompile(`(\d+)(k|m|g|t)?`) + sizeRegexp = regexp.MustCompile(`^(\d+)(k|m|g|t)?$`) // ErrInvalidSize is returned by ParseSize if input was not a valid size ErrInvalidSize = errors.New("invalid size") diff --git a/components/ws-daemon/pkg/quota/size_test.go b/components/ws-daemon/pkg/quota/size_test.go index cc21ae2579b1a2..68b3b822eb51cd 100644 --- a/components/ws-daemon/pkg/quota/size_test.go +++ b/components/ws-daemon/pkg/quota/size_test.go @@ -23,8 +23,8 @@ func TestParseSize(t *testing.T) { {"42m", 42 * quota.Megabyte, nil}, {"42g", 42 * quota.Gigabyte, nil}, {"42t", 42 * quota.Terabyte, nil}, - // This test should fail but doesn't because match somehow matches the regexp - // {"-42m", 0, quota.ErrInvalidSize}, + {"-42m", 0, quota.ErrInvalidSize}, + {"x42mx", 0, quota.ErrInvalidSize}, {"abc", 0, quota.ErrInvalidSize}, {"99999999999999999999999999999999999999999999999999999999999999999999999999999999", 0, quota.ErrInvalidSize}, }