mirror of
https://github.com/go-ini/ini.git
synced 2026-06-19 21:46:45 +02:00
Fix python multiline EOF error (#309)
This commit is contained in:
+23
@@ -1562,3 +1562,26 @@ func TestPythonMultiline(t *testing.T) {
|
||||
testData.Value3,
|
||||
)
|
||||
}
|
||||
|
||||
func TestPythonMultiline_EOF(t *testing.T) {
|
||||
if runtime.GOOS == "windows" {
|
||||
t.Skip("Skipping testing on Windows")
|
||||
}
|
||||
|
||||
path := filepath.Join("testdata", "multiline_eof.ini")
|
||||
f, err := LoadSources(LoadOptions{
|
||||
AllowPythonMultilineValues: true,
|
||||
ReaderBufferSize: 64 * 1024,
|
||||
}, path)
|
||||
require.NoError(t, err)
|
||||
require.NotNil(t, f)
|
||||
assert.Len(t, f.Sections(), 1)
|
||||
|
||||
defaultSection := f.Section("")
|
||||
assert.NotNil(t, f.Section(""))
|
||||
|
||||
var testData testData
|
||||
err = defaultSection.MapTo(&testData)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, "some text here\n\tsome more text here 2", testData.Value1)
|
||||
}
|
||||
|
||||
@@ -304,12 +304,7 @@ func (p *parser) readPythonMultilines(line string, bufferSize int) (string, erro
|
||||
|
||||
for {
|
||||
peekData, peekErr := peekBuffer.ReadBytes('\n')
|
||||
if peekErr != nil {
|
||||
if peekErr == io.EOF {
|
||||
p.debug("readPythonMultilines: io.EOF, peekData: %q, line: %q", string(peekData), line)
|
||||
return line, nil
|
||||
}
|
||||
|
||||
if peekErr != nil && peekErr != io.EOF {
|
||||
p.debug("readPythonMultilines: failed to peek with error: %v", peekErr)
|
||||
return "", peekErr
|
||||
}
|
||||
|
||||
Vendored
+2
@@ -0,0 +1,2 @@
|
||||
value1 = some text here
|
||||
some more text here 2
|
||||
Reference in New Issue
Block a user