Skip to content

Commit 3b395a9

Browse files
authored
Merge pull request #5074 from plobsing/master
Only strip surrounding quotes if there are at least two characters.
2 parents e07b8a5 + 633da99 commit 3b395a9

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

api/krusty/configmaps_test.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -571,3 +571,23 @@ metadata:
571571
name: test-k9cc55dfm5
572572
`)
573573
}
574+
575+
func TestDataIsSingleQuote(t *testing.T) {
576+
th := kusttest_test.MakeHarness(t)
577+
th.WriteK(".", `
578+
configMapGenerator:
579+
- name: test
580+
literals:
581+
- TEST='
582+
`)
583+
584+
m := th.Run(".", th.MakeDefaultOptions())
585+
th.AssertActualEqualsExpected(
586+
m, `apiVersion: v1
587+
data:
588+
TEST: ''''
589+
kind: ConfigMap
590+
metadata:
591+
name: test-m8t7bmb6g2
592+
`)
593+
}

api/kv/kv.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ func parseLiteralSource(source string) (keyName, value string, err error) {
187187
// removeQuotes removes the surrounding quotes from the provided string only if it is surrounded on both sides
188188
// rather than blindly trimming all quotation marks on either side.
189189
func removeQuotes(str string) string {
190-
if len(str) == 0 || str[0] != str[len(str)-1] {
190+
if len(str) < 2 || str[0] != str[len(str)-1] {
191191
return str
192192
}
193193
if str[0] == '"' || str[0] == '\'' {

0 commit comments

Comments
 (0)