Skip to content

Commit

Permalink
fix: check empty registry name
Browse files Browse the repository at this point in the history
Signed-off-by: Shiwei Zhang <[email protected]>
  • Loading branch information
shizhMSFT committed Mar 19, 2024
1 parent 8d139f0 commit 65b4359
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion registry/reference.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ func (r Reference) Validate() error {

// ValidateRegistry validates the registry.
func (r Reference) ValidateRegistry() error {
if uri, err := url.ParseRequestURI("dummy://" + r.Registry); err != nil || uri.Host != r.Registry {
if uri, err := url.ParseRequestURI("dummy://" + r.Registry); err != nil || uri.Host == "" || uri.Host != r.Registry {
return fmt.Errorf("%w: invalid registry %q", errdef.ErrInvalidReference, r.Registry)
}
return nil
Expand Down
4 changes: 4 additions & 0 deletions registry/reference_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@ func TestParseReferenceUglies(t *testing.T) {
name: "missing registry",
raw: "hello-world:linux",
},
{
name: "missing registry (issue #698)",
raw: "/hello-world:linux",
},
{
name: "invalid repo name",
raw: "localhost/UPPERCASE/test",
Expand Down

0 comments on commit 65b4359

Please sign in to comment.