Bugfix: incorrect logic in the parsing of comments fails to detect EOF properly
This commit is contained in:
parent
1dccd4b2ef
commit
3b0c9eafa4
|
@ -225,19 +225,21 @@ proc skipWhitespace(lexer: var JsonLexer) =
|
|||
checkForUnexpectedEof()
|
||||
case lexer.stream.peek()
|
||||
of '/':
|
||||
advance lexer.stream
|
||||
while true:
|
||||
advance lexer.stream
|
||||
if not lexer.stream.readable: return
|
||||
case lexer.stream.peek()
|
||||
of '\r':
|
||||
handleCR()
|
||||
break
|
||||
of '\n':
|
||||
lexer.handleLF()
|
||||
break
|
||||
else:
|
||||
discard
|
||||
advance lexer.stream
|
||||
of '*':
|
||||
advance lexer.stream
|
||||
while true:
|
||||
advance lexer.stream
|
||||
if not lexer.stream.readable: return
|
||||
case lexer.stream.peek()
|
||||
of '\r':
|
||||
|
@ -249,9 +251,9 @@ proc skipWhitespace(lexer: var JsonLexer) =
|
|||
checkForUnexpectedEof()
|
||||
if lexer.stream.peek() == '/':
|
||||
advance lexer.stream
|
||||
return
|
||||
break
|
||||
else:
|
||||
discard
|
||||
advance lexer.stream
|
||||
else:
|
||||
error errCommentExpected
|
||||
of ' ', '\t':
|
||||
|
|
|
@ -261,3 +261,13 @@ suite "toJson tests":
|
|||
test "Holders of JsonNode":
|
||||
testJsonHolders HasJsonNode
|
||||
|
||||
test "Json with comments":
|
||||
const jsonContent = staticRead "./cases/comments.json"
|
||||
|
||||
try:
|
||||
let decoded = Json.decode(jsonContent, JsonNode)
|
||||
check decoded["tasks"][0]["label"] == newJString("nim-beacon-chain build")
|
||||
except SerializationError as err:
|
||||
checkpoint err.formatMsg("./cases/comments.json")
|
||||
fail
|
||||
|
||||
|
|
Loading…
Reference in New Issue