]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
Stub function to handle escapes
authorCloudwalk <cloudwalk009@gmail.com>
Mon, 10 May 2021 17:54:20 +0000 (13:54 -0400)
committerCloudwalk <cloudwalk009@gmail.com>
Mon, 10 May 2021 17:54:20 +0000 (13:54 -0400)
json.c

diff --git a/json.c b/json.c
index b7ad7cb4a5caa5e5b8cd94fe34ed46e29e76d8bd..7e7373cb556ce2fb2cd1631aa1187f6bb0d9a2d3 100644 (file)
--- 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 != '"');
 }