env: Remove quotes when parsing a config env file (#13953)

The code parsing the config environment file does not remove 
quotes of environment variables values. This commit adds this 
capability.
This commit is contained in:
Anis Elleuch authored and GitHub committed 2021-12-20 13:13:06 -08:00
1 parent 364e27d5f2
commit 5cc16e098c
2 files changed
+34 -2

No files matched your search

+14 -2
View File
@@ -460,9 +460,21 @@ func parsEnvEntry(envEntry string) (envKV, error) {
if len(envTokens) != 2 {
return envKV{}, fmt.Errorf("envEntry malformed; %s, expected to be of form 'KEY=value'", envEntry)
}
key := envTokens[0]
val := envTokens[1]
// Remove quotes from the value if found
if len(val) >= 2 {
quote := val[0]
if (quote == '"' || quote == '\'') && val[len(val)-1] == quote {
val = val[1 : len(val)-1]
}
}
return envKV{
Key: envTokens[0],
Value: envTokens[1],
Key: key,
Value: val,
}, nil
}