Decode: allow \r\n as line whitespace before \ (#709)

Fixes #708
This commit is contained in:
Thomas Pelletier
2021-12-26 16:38:15 +01:00
committed by GitHub
parent 5cbdea6192
commit 177b4a5e53
2 changed files with 11 additions and 0 deletions
+4
View File
@@ -578,6 +578,10 @@ func (p *parser) parseMultilineBasicString(b []byte) ([]byte, []byte, []byte, er
switch token[i+j] {
case ' ', '\t':
continue
case '\r':
if token[i+j+1] == '\n' {
continue
}
case '\n':
isLastNonWhitespaceOnLine = true
}
+7
View File
@@ -2304,6 +2304,13 @@ func TestIssue703(t *testing.T) {
require.Error(t, err)
}
func TestIssue708(t *testing.T) {
v := map[string]string{}
err := toml.Unmarshal([]byte("0=\"\"\"\\\r\n\"\"\""), &v)
require.NoError(t, err)
require.Equal(t, map[string]string{"0": ""}, v)
}
func TestUnmarshalDecodeErrors(t *testing.T) {
examples := []struct {
desc string