mod_adhoc: Add support for commands only executable by global administrators
[prosody.git] / util / json.lua
index 05453703369e35f642b11acd61c33f93c5e2a97e..cfa84a4b24b88bf6c7daf41a1754492cfef261be 100644 (file)
@@ -134,12 +134,14 @@ end
 
 
 function json.decode(json)
+       json = json.." "; -- appending a space ensures valid json wouldn't touch EOF
        local pos = 1;
        local current = {};
        local stack = {};
        local ch, peek;
        local function next()
                ch = json:sub(pos, pos);
+               if ch == "" then error("Unexpected EOF"); end
                pos = pos+1;
                peek = json:sub(pos, pos);
                return ch;