summaryrefslogtreecommitdiffhomepage
path: root/cmd
diff options
context:
space:
mode:
authorMatt Holt <[email protected]>2023-04-10 13:55:45 -0600
committerGitHub <[email protected]>2023-04-10 13:55:45 -0600
commit205b142614d5de08ffc33a04ae4cfc00e65b5dfc (patch)
tree642829465473803c48c074976d92d99aaa36e30f /cmd
parentff35ba9ec33aabec93ed1409628cd6f1a3ceee5e (diff)
downloadcaddy-205b142614d5de08ffc33a04ae4cfc00e65b5dfc.tar.gz
caddy-205b142614d5de08ffc33a04ae4cfc00e65b5dfc.zip
cmd: Support `'` quotes in envfile parsing (#5437)
Diffstat (limited to 'cmd')
-rw-r--r--cmd/main.go13
1 files changed, 7 insertions, 6 deletions
diff --git a/cmd/main.go b/cmd/main.go
index 17da8bd07..96debdf01 100644
--- a/cmd/main.go
+++ b/cmd/main.go
@@ -374,18 +374,19 @@ func parseEnvFile(envInput io.Reader) (map[string]string, error) {
}
// quoted value: support newlines
- if strings.HasPrefix(val, `"`) {
- for !(strings.HasSuffix(line, `"`) && !strings.HasSuffix(line, `\"`)) {
- val = strings.ReplaceAll(val, `\"`, `"`)
+ if strings.HasPrefix(val, `"`) || strings.HasPrefix(val, "'") {
+ quote := string(val[0])
+ for !(strings.HasSuffix(line, quote) && !strings.HasSuffix(line, `\`+quote)) {
+ val = strings.ReplaceAll(val, `\`+quote, quote)
if !scanner.Scan() {
break
}
lineNumber++
- line = strings.ReplaceAll(scanner.Text(), `\"`, `"`)
+ line = strings.ReplaceAll(scanner.Text(), `\`+quote, quote)
val += "\n" + line
}
- val = strings.TrimPrefix(val, `"`)
- val = strings.TrimSuffix(val, `"`)
+ val = strings.TrimPrefix(val, quote)
+ val = strings.TrimSuffix(val, quote)
}
envMap[key] = val