mirror of
https://github.com/netbirdio/easyjson.git
synced 2026-05-22 18:44:42 -07:00
Merge pull request #56 from velanse/master
SkipRecursive fails while having double slashes at the end of the string
This commit is contained in:
+6
-3
@@ -506,7 +506,7 @@ func (r *Lexer) SkipRecursive() {
|
||||
return
|
||||
}
|
||||
case c == '\\' && inQuotes:
|
||||
wasEscape = true
|
||||
wasEscape = !wasEscape
|
||||
continue
|
||||
case c == '"' && inQuotes:
|
||||
inQuotes = wasEscape
|
||||
@@ -516,8 +516,11 @@ func (r *Lexer) SkipRecursive() {
|
||||
wasEscape = false
|
||||
}
|
||||
r.pos = len(r.Data)
|
||||
r.err = io.EOF
|
||||
}
|
||||
r.err = &LexerError{
|
||||
Reason: "EOF reached while skipping array/object or token",
|
||||
Offset: r.pos,
|
||||
Data: string(r.Data[r.pos:]),
|
||||
}}
|
||||
|
||||
// Raw fetches the next item recursively as a data slice
|
||||
func (r *Lexer) Raw() []byte {
|
||||
|
||||
@@ -157,6 +157,9 @@ func TestSkipRecursive(t *testing.T) {
|
||||
{toParse: `{"a\"}":1}, 4`, left: ", 4"},
|
||||
{toParse: `{"a{":1}, 4`, left: ", 4"},
|
||||
{toParse: `{"a\"{":1}, 4`, left: ", 4"},
|
||||
|
||||
// object with double slashes at the end of string
|
||||
{toParse: `{"a":"hey\\"}, 4`, left: ", 4"},
|
||||
} {
|
||||
l := Lexer{Data: []byte(test.toParse)}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user