json: add '\v' support, fixes #10541 (#10987)

This commit is contained in:
Miran 2019-04-10 15:54:49 +02:00 • committed by Andreas Rumpf
commit 2608bc369e
2 changed files with 4 additions and 0 deletions

View file

@ -636,6 +636,7 @@ proc escapeJsonUnquoted*(s: string; result: var string) =
of '\b': result.add("\\b") of '\b': result.add("\\b")
of '\f': result.add("\\f") of '\f': result.add("\\f")
of '\t': result.add("\\t") of '\t': result.add("\\t")
of '\v': result.add("\\v")
of '\r': result.add("\\r") of '\r': result.add("\\r")
of '"': result.add("\\\"") of '"': result.add("\\\"")
of '\0'..'\7': result.add("\\u000" & $ord(c)) of '\0'..'\7': result.add("\\u000" & $ord(c))

View file

@ -217,6 +217,9 @@ proc parseString(my: var JsonParser): TokKind =
of 't': of 't':
add(my.a, '\t') add(my.a, '\t')
inc(pos, 2) inc(pos, 2)
of 'v':
add(my.a, '\v')
inc(pos, 2)
of 'u': of 'u':
if my.rawStringLiterals: if my.rawStringLiterals:
add(my.a, 'u') add(my.a, 'u')