mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-09-15 12:18:57 +00:00
Only strip surrounding quotes if there are at least two characters.
Otherwise, a value consisting of a single quote character triggers a
panic:
go test krusty/configmaps_test.go
--- FAIL: TestDataIsSingleQuote (0.00s)
panic: runtime error: slice bounds out of range [1:0] [recovered]
panic: runtime error: slice bounds out of range [1:0]
This commit is contained in:
@@ -187,7 +187,7 @@ func parseLiteralSource(source string) (keyName, value string, err error) {
|
||||
// removeQuotes removes the surrounding quotes from the provided string only if it is surrounded on both sides
|
||||
// rather than blindly trimming all quotation marks on either side.
|
||||
func removeQuotes(str string) string {
|
||||
if len(str) == 0 || str[0] != str[len(str)-1] {
|
||||
if len(str) < 2 || str[0] != str[len(str)-1] {
|
||||
return str
|
||||
}
|
||||
if str[0] == '"' || str[0] == '\'' {
|
||||
|
||||
Reference in New Issue
Block a user