hare

[hare] The Hare programming language
git clone https://git.torresjrjr.com/hare.git
Log | Files | Refs | README | LICENSE

commit 46989986af14e7345f85b3f481030f8c7fe07dc4
parent f20f3a7b8ececdd939f47d3bee4ab9449c1e339f
Author: Sebastian <sebastian@sebsite.pw>
Date:   Sat, 14 May 2022 22:46:15 -0400

encoding::json: disallow unescaped control char in string

Signed-off-by: Sebastian <sebastian@sebsite.pw>

Diffstat:
Mencoding/json/lex.ha | 5+++++
1 file changed, 5 insertions(+), 0 deletions(-)

diff --git a/encoding/json/lex.ha b/encoding/json/lex.ha @@ -250,6 +250,9 @@ fn scan_str(lex: *lexer) (token | error) = { const rn = scan_escape(lex)?; strio::appendrune(&lex.strbuf, rn)!; case => + if (iscntrl(rn)) { + return invalid; + }; strio::appendrune(&lex.strbuf, rn)!; }; }; @@ -346,3 +349,5 @@ fn unget(lex: *lexer, r: rune) void = { assert(lex.rb is void); lex.rb = r; }; + +fn iscntrl(r: rune) bool = r: u32 < 0x20;