Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions util/path.go
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,12 @@ func SplitPath(path string) []string {
inKey = true
case ch == ']' && !inEscape:
inKey = false
case ch == '\\' && !inEscape && inKey:
// Keep escapes inside keys intact for the key parser, but honor
// them here so an escaped ] does not prematurely end the key.
inEscape = true
buf.WriteRune(ch)
continue
case ch == '\\' && !inEscape && !inKey:
inEscape = true
continue
Expand Down
6 changes: 6 additions & 0 deletions util/path_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1017,6 +1017,12 @@ func TestSplitPath(t *testing.T) {
want: []string{"a", `b[key1 = ../x/y key2 = "z"]`, "c"},
wantIgnoreLeadingTrailing: []string{"a", `b[key1 = ../x/y key2 = "z"]`, "c"},
},
{
desc: "escaped bracket then slash in key",
in: `a/b[k=x\]/y]/c`,
want: []string{"a", `b[k=x\]/y]`, "c"},
wantIgnoreLeadingTrailing: []string{"a", `b[k=x\]/y]`, "c"},
},
}

for _, tt := range tests {
Expand Down
Loading