X-Git-Url: https://git.enpas.org/?a=blobdiff_plain;f=util%2Fjson.lua;h=cfa84a4b24b88bf6c7daf41a1754492cfef261be;hb=0d3a399b188ac9981f47256bc500007fdcb2bf27;hp=40939bb4626f80366c8d037f1f78cff5fa1992d7;hpb=267028349b6bddbe984edc8c1c2380a2e6765ff6;p=prosody.git diff --git a/util/json.lua b/util/json.lua index 40939bb4..cfa84a4b 100644 --- a/util/json.lua +++ b/util/json.lua @@ -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; @@ -268,7 +270,9 @@ function json.decode(json) return tonumber(s); end local function readmember(t) + skipstuff(); local k = readstring(); + skipstuff(); checkandskip(":"); t[k] = readvalue(); end