Skip to content

Commit 273aca9

Browse files
author
Matthew Fisher
committed
Merge pull request #3213 from bacongobbler/revert-escape-backticks
Revert "properly escape backticks in envvars"
2 parents 54badc5 + 5f395db commit 273aca9

6 files changed

Lines changed: 16 additions & 17 deletions

File tree

builder/bin/get-app-values.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,7 @@ func main() {
2626
os.Exit(1)
2727
}
2828

29-
var retVal string
3029
for _, value := range values {
31-
retVal = fmt.Sprintf("%s%s", retVal, value)
30+
fmt.Println(value)
3231
}
33-
fmt.Println(retVal)
3432
}

builder/image/slugbuilder/builder/build.sh

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,6 @@ selected_buildpack=
7777
if [[ -n "$BUILDPACK_URL" ]]; then
7878
echo_title "Fetching custom buildpack"
7979

80-
# FIXME: strip single quotes coming from the builder
81-
BUILDPACK_URL=$(echo $BUILDPACK_URL | tr -d "'")
82-
8380
buildpack="$buildpack_root/custom"
8481
rm -fr "$buildpack"
8582

builder/image/templates/builder

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,14 @@ usage() {
2727
echo "Usage: $0 <user> <repo> <sha>"
2828
}
2929

30+
parse-string(){
31+
# helper to avoid the single quote escape
32+
# occurred in command substitution
33+
local args=() idx=0 IFS=' ' c
34+
for c; do printf -v args[idx++] '%s ' "$c"; done
35+
printf "%s\n" "${args[*]}"
36+
}
37+
3038
if [ $# -ne $ARGS ]; then
3139
usage
3240
exit 1
@@ -105,7 +113,7 @@ if [ ! -f Dockerfile ]; then
105113
BUILD_OPTS+=' deis/slugbuilder'
106114

107115
# build the application and attach to the process
108-
JOB=$(${BUILD_OPTS[@]})
116+
JOB=$(eval $(parse-string "${BUILD_OPTS[@]}") )
109117
docker attach $JOB
110118

111119
# copy out the compiled slug

builder/utils.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ func ParseControllerConfig(bytes []byte) ([]string, error) {
109109

110110
retVal := []string{}
111111
for k, v := range controllerConfig.Values {
112-
retVal = append(retVal, fmt.Sprintf(" -e %s='%v'", k, v))
112+
retVal = append(retVal, fmt.Sprintf(" -e %s=\"%v\"", k, v))
113113
}
114114
return retVal, nil
115115
}

builder/utils_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,8 @@ func TestParseControllerConfigGood(t *testing.T) {
163163
t.Errorf("expected 2, got %d", len(config))
164164
}
165165

166-
if !stringInSlice(config, " -e CAR='star'") {
167-
t.Error("expected ' -e CAR='star'' in slice")
166+
if !stringInSlice(config, " -e CAR=\"star\"") {
167+
t.Error("expected ' -e CAR=\"star\"' in slice")
168168
}
169169
}
170170

tests/config_test.go

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ var (
1313
configSetCmd = "config:set FOO=讲台 --app={{.AppName}}"
1414
configSet2Cmd = "config:set FOO=10 --app={{.AppName}}"
1515
configSet3Cmd = "config:set POWERED_BY=\"the Deis team\" --app={{.AppName}}"
16-
configSet4Cmd = "config:set CAR='`star' --app={{.AppName}}"
1716
configSetBuildpackCmd = "config:set BUILDPACK_URL=https://github.com/heroku/heroku-buildpack-go#98f37cc --app={{.AppName}}"
1817
configUnsetCmd = "config:unset FOO --app={{.AppName}}"
1918
)
@@ -46,9 +45,6 @@ func configSetup(t *testing.T) *utils.DeisTestConfig {
4645
// ensure envvars with spaces work fine on `git push`
4746
// https://github.com/deis/deis/issues/2477
4847
utils.Execute(t, configSet3Cmd, cfg, false, "the Deis team")
49-
// ensure envvars with backticks work too
50-
// https://github.com/deis/deis/issues/2980
51-
utils.Execute(t, configSet4Cmd, cfg, false, "`star")
5248
// ensure custom buildpack URLS are in order
5349
utils.Execute(t, configSetBuildpackCmd, cfg, false, "https://github.com/heroku/heroku-buildpack-go#98f37cc")
5450
utils.Execute(t, gitPushCmd, cfg, false, "")
@@ -66,13 +62,13 @@ func configListTest(
6662

6763
func configSetTest(t *testing.T, params *utils.DeisTestConfig) {
6864
utils.Execute(t, configSetCmd, params, false, "讲台")
69-
utils.CheckList(t, appsInfoCmd, params, "(v6)", false)
65+
utils.CheckList(t, appsInfoCmd, params, "(v5)", false)
7066
utils.Execute(t, configSet2Cmd, params, false, "10")
71-
utils.CheckList(t, appsInfoCmd, params, "(v7)", false)
67+
utils.CheckList(t, appsInfoCmd, params, "(v6)", false)
7268
}
7369

7470
func configUnsetTest(t *testing.T, params *utils.DeisTestConfig) {
7571
utils.Execute(t, configUnsetCmd, params, false, "")
76-
utils.CheckList(t, appsInfoCmd, params, "(v8)", false)
72+
utils.CheckList(t, appsInfoCmd, params, "(v7)", false)
7773
utils.CheckList(t, "run env --app={{.AppName}}", params, "FOO", true)
7874
}

0 commit comments

Comments
 (0)