Don't allow empty env names

Closes: #25281

Signed-off-by: Doug Davis <dug@us.ibm.com>
Upstream-commit: e72c0137af63c2f5aecce48443e3b654a3895150
Component: engine
This commit is contained in:
Doug Davis
2016-08-01 09:38:05 -07:00
parent c972743442
commit bb00cee2aa
2 changed files with 50 additions and 0 deletions

View File

@ -66,6 +66,11 @@ func env(b *Builder, args []string, attributes map[string]bool, original string)
for j := 0; j < len(args); j++ {
// name ==> args[j]
// value ==> args[j+1]
if len(args[j]) == 0 {
return fmt.Errorf("ENV names can not be blank")
}
newVar := args[j] + "=" + args[j+1] + ""
commitStr += " " + newVar
@ -129,6 +134,11 @@ func label(b *Builder, args []string, attributes map[string]bool, original strin
for j := 0; j < len(args); j++ {
// name ==> args[j]
// value ==> args[j+1]
if len(args[j]) == 0 {
return fmt.Errorf("LABEL names can not be blank")
}
newVar := args[j] + "=" + args[j+1] + ""
commitStr += " " + newVar
@ -696,6 +706,10 @@ func arg(b *Builder, args []string, attributes map[string]bool, original string)
// name-value pair). If possible, it will be good to harmonize the two.
if strings.Contains(arg, "=") {
parts := strings.SplitN(arg, "=", 2)
if len(parts[0]) == 0 {
return fmt.Errorf("ARG names can not be blank")
}
name = parts[0]
value = parts[1]
hasDefault = true