From 389670bd79faf96b610b4a4b85d1a147283dc984 Mon Sep 17 00:00:00 2001 From: Cloudwalk Date: Mon, 10 May 2021 13:54:20 -0400 Subject: [PATCH] Stub function to handle escapes --- json.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/json.c b/json.c index b7ad7cb4..7e7373cb 100644 --- a/json.c +++ b/json.c @@ -84,6 +84,23 @@ static qbool Json_Parse_CheckComment_Multiline_End(struct qparser_state_s *state return false; } +static inline qbool Json_Handle_String_Escape(struct qjson_state_s *json) +{ + switch(*json->state->pos) + { + case '\\': + case '/': + case 'b': + case 'f': + case 'n': + case 'r': + case 't': + case 'u': + return true; // TODO + default: + return false; + } +} // TODO: handle escape sequences static inline void Json_Parse_String(struct qjson_state_s *json) @@ -93,7 +110,9 @@ static inline void Json_Parse_String(struct qjson_state_s *json) if(*json->state->pos == '\\') { Parse_Next(json->state, 1); - continue; + if(Json_Handle_String_Escape(json)) + continue; + Parse_Error(json->state, PARSE_ERR_INVAL, "a valid escape sequence"); } } while(*json->state->pos != '"'); } -- 2.39.2