From 97c56e6c7184b6a90f36ecffa6db00ac57772673 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Sat, 27 Oct 2018 12:17:35 +0200 Subject: util.serialization: Make maximum table depth configurable --- util/serialization.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'util') 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 -- cgit v1.2.3