Don't allow '/' in distribution name, auto-replace '/' with '-' while guessing. #110

This commit is contained in:
Andrey Smirnov
2014-10-01 22:59:05 +04:00
parent aeae6009c4
commit 1daa076d65
2 changed files with 17 additions and 0 deletions
+7
View File
@@ -168,6 +168,9 @@ func NewPublishedRepo(storage, prefix, distribution string, architectures []stri
if distribution == "" || component == "" {
rootDistributions, rootComponents := walkUpTree(source, collectionFactory)
if distribution == "" {
for i := range rootDistributions {
rootDistributions[i] = strings.Replace(rootDistributions[i], "/", "-", -1)
}
discoveredDistributions = append(discoveredDistributions, rootDistributions...)
}
if component == "" {
@@ -227,6 +230,10 @@ func NewPublishedRepo(storage, prefix, distribution string, architectures []stri
}
}
if strings.Index(distribution, "/") != -1 {
return nil, fmt.Errorf("invalid distribution %s, '/' is not allowed", distribution)
}
result.Distribution = distribution
return result, nil