M api/graph/resolver.go => api/graph/resolver.go +1 -1
@@ 9,5 9,5 @@ import (
type Resolver struct {}
var (
- repoNameRE = regexp.MustCompile(`^[A-Za-z._-][A-Za-z0-9._-]*$`)
+ repoNameRE = regexp.MustCompile(`^[A-Za-z0-9._-]+$`)
)
M api/graph/schema.resolvers.go => api/graph/schema.resolvers.go +3 -0
@@ 75,6 75,9 @@ func (r *mutationResolver) CreateRepository(ctx context.Context, name string, vi
if name == "." || name == ".." {
return nil, fmt.Errorf("Invalid repository name '%s' (must not be . or ..)", name)
}
+ if name == ".git" || name == ".hg" {
+ return nil, fmt.Errorf("Invalid repository name '%s' (must not be .git or .hg)", name)
+ }
conf := config.ForContext(ctx)
repoStore, ok := conf.Get("git.sr.ht", "repos")
M gitsrht-shell/main.go => gitsrht-shell/main.go +2 -2
@@ 264,9 264,9 @@ func main() {
if needsAccess == ACCESS_WRITE {
if matched, _ := regexp.MatchString(
- `^[A-Za-z._-][A-Za-z0-9._-]*$`, repoName); !matched {
+ `^[A-Za-z0-9._-]+$`, repoName); !matched {
- log.Println("Name must match [A-Za-z._-][A-Za-z0-9._-]*.")
+ log.Println("Name must match [A-Za-z0-9._-]+.")
notFound("name policy", nil)
}