Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
15 changes: 15 additions & 0 deletions ini_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,21 @@ key = test value <span style="color: %s\; background: %s">more text</span>
assert.Equal(t, `test value <span style="color: %s; background: %s">more text</span>`, f.Section("").Key("key").String())
})

t.Run("unescape double quotes with backslash continuation", func(t *testing.T) {
f, err := LoadSources(LoadOptions{
UnescapeValueDoubleQuotes: true,
}, []byte(`hello = "!f() { \
echo "hello world"; \
};f"`))
require.NoError(t, err)
require.NotNil(t, f)

expected := `!f() { \
echo "hello world"; \
};f`
assert.Equal(t, expected, f.Section("").Key("hello").String())
})

t.Run("can parse small python-compatible INI files", func(t *testing.T) {
f, err := LoadSources(LoadOptions{
AllowPythonMultilineValues: true,
Expand Down
7 changes: 7 additions & 0 deletions parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,13 @@ func (p *parser) readMultilines(line, val, valQuote string) (string, error) {

pos := strings.LastIndex(next, valQuote)
if pos > -1 {
// Check if the line ends with backslash continuation after the quote
restOfLine := strings.TrimRight(next[pos+len(valQuote):], "\r\n")
if !p.options.IgnoreContinuation && strings.HasSuffix(strings.TrimSpace(restOfLine), "\\") {
val += next
continue
}

val += next[:pos]

comment, has := cleanComment([]byte(next[pos:]))
Expand Down