mirror of https://github.com/docker/docs.git
Merge pull request #663 from dotcloud/662-fix_push_html_404-fix
* Registry: add regexp check on repo's name
This commit is contained in:
commit
165d343d06
10
commands.go
10
commands.go
|
@ -20,6 +20,7 @@ import (
|
||||||
"path"
|
"path"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"reflect"
|
"reflect"
|
||||||
|
"regexp"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"syscall"
|
"syscall"
|
||||||
|
@ -727,6 +728,15 @@ func (cli *DockerCli) CmdPush(args ...string) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
nameParts := strings.SplitN(name, "/", 2)
|
||||||
|
validNamespace := regexp.MustCompile(`^([a-z0-9_]{4,30})$`)
|
||||||
|
if !validNamespace.MatchString(nameParts[0]) {
|
||||||
|
return fmt.Errorf("Invalid namespace name (%s), only [a-z0-9_] are allowed, size between 4 and 30", nameParts[0])
|
||||||
|
}
|
||||||
|
validRepo := regexp.MustCompile(`^([a-zA-Z0-9-_.]+)$`)
|
||||||
|
if !validRepo.MatchString(nameParts[1]) {
|
||||||
|
return fmt.Errorf("Invalid repository name (%s), only [a-zA-Z0-9-_.] are allowed", nameParts[1])
|
||||||
|
}
|
||||||
|
|
||||||
v := url.Values{}
|
v := url.Values{}
|
||||||
v.Set("registry", *registry)
|
v.Set("registry", *registry)
|
||||||
|
|
Loading…
Reference in New Issue