Skip to content

Fix regex strings in gitpod-cli and ws-daemon #4843

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion components/gitpod-cli/cmd/preview.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion components/ws-daemon/pkg/quota/size.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const (
)

var (
sizeRegexp = regexp.MustCompile(`(\d+)(k|m|g|t)?`)
sizeRegexp = regexp.MustCompile(`^(\d+)(k|m|g|t)?$`)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made changes as requested by @corneliusludmann here


// ErrInvalidSize is returned by ParseSize if input was not a valid size
ErrInvalidSize = errors.New("invalid size")
Expand Down
4 changes: 2 additions & 2 deletions components/ws-daemon/pkg/quota/size_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made changes as requested by @corneliusludmann here

{"x42mx", 0, quota.ErrInvalidSize},
{"abc", 0, quota.ErrInvalidSize},
{"99999999999999999999999999999999999999999999999999999999999999999999999999999999", 0, quota.ErrInvalidSize},
}
Expand Down