Commit bff65940 authored by Jaromil's avatar Jaromil
Browse files

fix trimming json on parse

parent a56ad1ed
...@@ -134,11 +134,12 @@ static int lua_unserialize_json(lua_State* L) { ...@@ -134,11 +134,12 @@ static int lua_unserialize_json(lua_State* L) {
in = luaL_checklstring(L, 1, &size); in = luaL_checklstring(L, 1, &size);
p = (char*)in; p = (char*)in;
while (size && isspace(*p) ) { size--; p++; } // first char while (size && isspace(*p) ) { size--; p++; } // first char
while (size && (*p == 0x0) ) { size--; p++; } // first char
if(!size) { lua_pushnil(L); return 1; } if(!size) { lua_pushnil(L); return 1; }
if (*p == '{' || *p == '[') { if (*p == '{' || *p == '[') {
level++; level++;
} else { } else {
func(L, "JSON doesn't starts with '{', char found: %c", *p); func(L, "JSON doesn't starts with '{', char found: %c (%02x)", *p, *p);
lua_pushnil(L); lua_pushnil(L);
return 1; return 1;
} // ok, level is 1 } // ok, level is 1
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment