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
2 changes: 1 addition & 1 deletion parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -461,14 +461,14 @@ func (f *File) parse(reader io.Reader) (err error) {
if f.options.UnparseableSections[i] == name ||
((f.options.Insensitive || f.options.InsensitiveSections) && strings.EqualFold(f.options.UnparseableSections[i], name)) {
inUnparseableSection = true
section.isRawSection = true
continue
}
}
continue
}

if inUnparseableSection {
section.isRawSection = true
section.rawBody += string(line)
continue
}
Expand Down
12 changes: 12 additions & 0 deletions section_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,18 @@ import (
"github.com/stretchr/testify/require"
)

func TestEmptyUnparseableSection(t *testing.T) {
for _, input := range []string{"[raw]", "[raw]\n", "[raw]\n[next]\nkey=value"} {
t.Run(input, func(t *testing.T) {
f, err := LoadSources(LoadOptions{UnparseableSections: []string{"raw"}}, []byte(input))
require.NoError(t, err)
sec := f.Section("raw")
sec.SetBody("raw content")
assert.Equal(t, "raw content", sec.Body())
})
}
}

func TestSection_SetBody(t *testing.T) {
t.Run("set body of raw section", func(t *testing.T) {
f := Empty()
Expand Down