@@ -149,6 +149,12 @@ func scanComment(b []byte) ([]byte, []byte, error) {
|
||||
if b[i] == '\n' {
|
||||
return b[:i], b[i:], nil
|
||||
}
|
||||
if b[i] == '\r' {
|
||||
if i+1 < len(b) && b[i+1] == '\n' {
|
||||
return b[:i+1], b[i+1:], nil
|
||||
}
|
||||
return nil, nil, newDecodeError(b[i:i+1], "invalid character in comment")
|
||||
}
|
||||
size := utf8ValidNext(b[i:])
|
||||
if size == 0 {
|
||||
return nil, nil, newDecodeError(b[i:i+1], "invalid character in comment")
|
||||
|
||||
@@ -1557,6 +1557,18 @@ B = "data"`,
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
desc: "comment with CRLF",
|
||||
input: "# foo\r\na=2",
|
||||
gen: func() test {
|
||||
doc := map[string]interface{}{}
|
||||
|
||||
return test{
|
||||
target: &doc,
|
||||
expected: &map[string]interface{}{"a": int64(2)},
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for _, e := range examples {
|
||||
@@ -2219,6 +2231,14 @@ world'`,
|
||||
desc: `carriage return inside basic string`,
|
||||
data: "A = \"\r\"",
|
||||
},
|
||||
{
|
||||
desc: `carriage return in comment`,
|
||||
data: "# this is a test\ra=1",
|
||||
},
|
||||
{
|
||||
desc: `backspace in comment`,
|
||||
data: "# this is a test\ba=1",
|
||||
},
|
||||
}
|
||||
|
||||
for _, e := range examples {
|
||||
|
||||
Reference in New Issue
Block a user