mirror of
https://gitlab.com/luk3yx/minetest-formspec_ast.git
synced 2025-07-17 05:59:00 +02:00
Partially fix safe_parse on formspec version >= 3
This commit is contained in:
parent
9f28d8cae3
commit
86faeff45d
@ -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.
|
||||
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user