Changeset

9564:ed0090f8b709

util.serialization: Make maximum table depth configurable
author Kim Alvefur <zash@zash.se>
date Sat, 27 Oct 2018 12:17:35 +0200
parents 9563:732314eb3258
children 9565:9a1e2f5f674f
files util/serialization.lua
diffstat 1 files changed, 2 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/util/serialization.lua	Fri Oct 26 19:53:02 2018 +0100
+++ b/util/serialization.lua	Sat Oct 27 12:17:35 2018 +0200
@@ -119,6 +119,7 @@
 	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 @@
 	-- 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