aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2018-10-27 12:17:35 +0200
committerKim Alvefur <zash@zash.se>2018-10-27 12:17:35 +0200
commit956b687a20aa70f62ca803b671be7f8434e66e00 (patch)
tree7dfee8663c275078545155ddabdaab065c300b81
parentced9754f5b62912704bc27ea29244b47ac5f7b05 (diff)
downloadprosody-956b687a20aa70f62ca803b671be7f8434e66e00.tar.gz
prosody-956b687a20aa70f62ca803b671be7f8434e66e00.zip
util.serialization: Make maximum table depth configurable
-rw-r--r--util/serialization.lua3
1 files changed, 2 insertions, 1 deletions
diff --git a/util/serialization.lua b/util/serialization.lua
index 64497382..401bf6f8 100644
--- a/util/serialization.lua
+++ b/util/serialization.lua
@@ -119,6 +119,7 @@ local function new(opt)
local unquoted = opt.unquoted == nil and "^[%a_][%w_]*$" or opt.unquoted;
local hex = opt.hex;
local freeze = opt.freeze;
+ local maxdepth = opt.maxdepth or 127;
-- serialize one table, recursively
-- t - table being serialized
@@ -127,7 +128,7 @@ local function new(opt)
-- l - position in o of where to insert next token
-- d - depth, used for indentation
local function serialize_table(t, o, l, d)
- if o[t] or d > 127 then
+ if o[t] or d > maxdepth then
o[l], l = fallback(t, "recursion"), l + 1;
return l;
end