projects
/
prosody.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
3eb2b3b
)
util.json: Fixed handling of truncated JSON.
author
Waqas Hussain
<waqas20@gmail.com>
Thu, 2 Jun 2011 00:36:15 +0000
(
05:36
+0500)
committer
Waqas Hussain
<waqas20@gmail.com>
Thu, 2 Jun 2011 00:36:15 +0000
(
05:36
+0500)
util/json.lua
patch
|
blob
|
history
diff --git
a/util/json.lua
b/util/json.lua
index 05453703369e35f642b11acd61c33f93c5e2a97e..cfa84a4b24b88bf6c7daf41a1754492cfef261be 100644
(file)
--- 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;