Decoder: flag invalid carriage returns in literal strings (#673)
This commit is contained in:
+1
-1
@@ -53,7 +53,7 @@ func scanLiteralString(b []byte) ([]byte, []byte, error) {
|
||||
switch b[i] {
|
||||
case '\'':
|
||||
return b[:i+1], b[i+1:], nil
|
||||
case '\n':
|
||||
case '\n', '\r':
|
||||
return nil, nil, newDecodeError(b[i:i+1], "literal strings cannot have new lines")
|
||||
}
|
||||
size := utf8ValidNext(b[i:])
|
||||
|
||||
@@ -2544,10 +2544,18 @@ world'`,
|
||||
desc: `carriage return inside basic key`,
|
||||
data: "\"\r\"=42",
|
||||
},
|
||||
{
|
||||
desc: `carriage return inside literal key`,
|
||||
data: "'\r'=42",
|
||||
},
|
||||
{
|
||||
desc: `carriage return inside basic string`,
|
||||
data: "A = \"\r\"",
|
||||
},
|
||||
{
|
||||
desc: `carriage return inside literal string`,
|
||||
data: "A = '\r'",
|
||||
},
|
||||
{
|
||||
desc: `carriage return in comment`,
|
||||
data: "# this is a test\ra=1",
|
||||
|
||||
Reference in New Issue
Block a user