Use formspec_escape when available.

This commit is contained in:
Anthony Zhang 2013-03-15 17:21:16 -04:00
parent e1211729cc
commit 5fd1cf5c80

View File

@ -283,14 +283,15 @@ end
local reset_meta = function(pos, code, errmsg) local reset_meta = function(pos, code, errmsg)
local meta = minetest.env:get_meta(pos) local meta = minetest.env:get_meta(pos)
code = code or ""; if minetest.formspec_escape then
code = string.gsub(code, "%[", "(") -- would otherwise code = minetest.formspec_escape(code or "")
code = string.gsub(code, "%]", ")") -- corrupt formspec errmsg = minetest.formspec_escape(errmsg or "")
errmsg = errmsg or ""; else
errmsg = string.gsub(errmsg, "%[", "(") -- would otherwise code = string.gsub(code or "", "%[", "(") -- would otherwise
errmsg = string.gsub(errmsg, "%]", ")") -- corrupt formspec code = string.gsub(code, "%]", ")") -- corrupt formspec
--code = minetest.formspec_escape(code or "") errmsg = string.gsub(errmsg or "", "%[", "(") -- would otherwise
--errmsg = minetest.formspec_escape(errmsg or "") errmsg = string.gsub(errmsg, "%]", ")") -- corrupt formspec
end
meta:set_string("code", code) meta:set_string("code", code)
meta:set_string("formspec", "size[10,8]".. meta:set_string("formspec", "size[10,8]"..
"background[-0.2,-0.25;10.4,8.75;jeija_luac_background.png]".. "background[-0.2,-0.25;10.4,8.75;jeija_luac_background.png]"..