summaryrefslogtreecommitdiff
path: root/lua_cjson.c
diff options
context:
space:
mode:
Diffstat (limited to 'lua_cjson.c')
-rw-r--r--lua_cjson.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/lua_cjson.c b/lua_cjson.c
index 52b259d..179c830 100644
--- a/lua_cjson.c
+++ b/lua_cjson.c
@@ -1167,6 +1167,14 @@ static int json_decode(lua_State *l)
1167 1167
1168 json = luaL_checklstring(l, 1, &len); 1168 json = luaL_checklstring(l, 1, &len);
1169 1169
1170 /* Detect Unicode other than UTF-8 (see RFC 4627, Sec 3)
1171 *
1172 * CJSON can support any simple data type, hence only the first
1173 * character is guaranteed to be ASCII (at worst: "). This is
1174 * still enough to detect whether the wrong encoding is in use. */
1175 if (len >= 2 && (!json[0] || !json[1]))
1176 luaL_error(l, "JSON parser does not support UTF-16 or UTF-32");
1177
1170 lua_json_decode(l, json, len); 1178 lua_json_decode(l, json, len);
1171 1179
1172 return 1; 1180 return 1;