Partially fix safe_parse on formspec version >= 3

This commit is contained in:
luk3yx 2021-02-05 14:18:36 +13:00
parent 9f28d8cae3
commit 86faeff45d
2 changed files with 2 additions and 2 deletions

View File

@ -31,7 +31,7 @@ A Minetest mod library to make modifying formspecs easier.
pass `formspec` through `formspec_ast.interpret` first.
- `formspec_ast.safe_parse(string_or_tree)`: Similar to `formspec_ast.parse`,
however will delete any elements that may crash the client (or any I
haven't added to the whitelist).
haven't added to the safe element list).
- `formspec_ast.formspec_escape(text)`: The same as `minetest.formspec_escape`,
should only be used when formspec_ast is being embedded outside of Minetest.

View File

@ -50,7 +50,7 @@ end
-- Similar to ast.flatten(), however removes unsafe elements.
local function safe_flatten(tree)
local res = {formspec_version = 1}
if tree.formspec_version == 2 then
if tree.formspec_version and tree.formspec_version > 1 then
res.formspec_version = 2
end
for elem in safe_walk(table.copy(tree)) do