mirror of
https://github.com/goccy/go-yaml.git
synced 2025-12-08 06:09:57 +00:00
Add support for multi-line double-quoted strings with CRLF line endings (#744)
This commit is contained in:
parent
f1c23f747b
commit
680eea761f
2 changed files with 23 additions and 0 deletions
|
|
@ -468,6 +468,18 @@ func TestDecoder(t *testing.T) {
|
||||||
source: "'1': \"2\\r\\n3\"",
|
source: "'1': \"2\\r\\n3\"",
|
||||||
value: map[interface{}]interface{}{"1": "2\r\n3"},
|
value: map[interface{}]interface{}{"1": "2\r\n3"},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
source: "'1': \"a\\\nb\\\nc\"",
|
||||||
|
value: map[interface{}]interface{}{"1": "abc"},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
source: "'1': \"a\\\r\nb\\\r\nc\"",
|
||||||
|
value: map[interface{}]interface{}{"1": "abc"},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
source: "'1': \"a\\\rb\\\rc\"",
|
||||||
|
value: map[interface{}]interface{}{"1": "abc"},
|
||||||
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
source: "a: -b_c",
|
source: "a: -b_c",
|
||||||
|
|
|
||||||
|
|
@ -522,6 +522,17 @@ func (s *Scanner) scanDoubleQuote(ctx *Context) (*token.Token, error) {
|
||||||
s.progressLine(ctx)
|
s.progressLine(ctx)
|
||||||
idx++
|
idx++
|
||||||
continue
|
continue
|
||||||
|
case '\r':
|
||||||
|
isFirstLineChar = true
|
||||||
|
isNewLine = true
|
||||||
|
ctx.addOriginBuf(nextChar)
|
||||||
|
s.progressLine(ctx)
|
||||||
|
progress = 1
|
||||||
|
// Skip \n after \r in CRLF sequences
|
||||||
|
if idx+2 < size && src[idx+2] == '\n' {
|
||||||
|
ctx.addOriginBuf('\n')
|
||||||
|
progress = 2
|
||||||
|
}
|
||||||
case '\t':
|
case '\t':
|
||||||
progress = 1
|
progress = 1
|
||||||
ctx.addOriginBuf(nextChar)
|
ctx.addOriginBuf(nextChar)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue