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] {
|
switch b[i] {
|
||||||
case '\'':
|
case '\'':
|
||||||
return b[:i+1], b[i+1:], nil
|
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")
|
return nil, nil, newDecodeError(b[i:i+1], "literal strings cannot have new lines")
|
||||||
}
|
}
|
||||||
size := utf8ValidNext(b[i:])
|
size := utf8ValidNext(b[i:])
|
||||||
|
|||||||
@@ -2544,10 +2544,18 @@ world'`,
|
|||||||
desc: `carriage return inside basic key`,
|
desc: `carriage return inside basic key`,
|
||||||
data: "\"\r\"=42",
|
data: "\"\r\"=42",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
desc: `carriage return inside literal key`,
|
||||||
|
data: "'\r'=42",
|
||||||
|
},
|
||||||
{
|
{
|
||||||
desc: `carriage return inside basic string`,
|
desc: `carriage return inside basic string`,
|
||||||
data: "A = \"\r\"",
|
data: "A = \"\r\"",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
desc: `carriage return inside literal string`,
|
||||||
|
data: "A = '\r'",
|
||||||
|
},
|
||||||
{
|
{
|
||||||
desc: `carriage return in comment`,
|
desc: `carriage return in comment`,
|
||||||
data: "# this is a test\ra=1",
|
data: "# this is a test\ra=1",
|
||||||
|
|||||||
Reference in New Issue
Block a user