summaryrefslogtreecommitdiff
path: root/builtin/misc_helpers.lua
diff options
context:
space:
mode:
authorNovatux <nathanael.courant@laposte.net>2013-08-14 20:21:39 +0200
committerKahrl <kahrl@gmx.net>2013-08-15 22:12:51 +0200
commit7921fe2cd1b284b35c28419fdf78873af456fded (patch)
tree8406671ea8106a6bef4ee384bf2a17f3dc384d15 /builtin/misc_helpers.lua
parenta97c085e9e6f5e37c316aa5390f7cb05ad6bcacc (diff)
downloadminetest-7921fe2cd1b284b35c28419fdf78873af456fded.tar.gz
minetest-7921fe2cd1b284b35c28419fdf78873af456fded.tar.bz2
minetest-7921fe2cd1b284b35c28419fdf78873af456fded.zip
Fix formspec escaping, add escaping to info.txt for texture packs.
Diffstat (limited to 'builtin/misc_helpers.lua')
-rw-r--r--builtin/misc_helpers.lua47
1 files changed, 13 insertions, 34 deletions
diff --git a/builtin/misc_helpers.lua b/builtin/misc_helpers.lua
index 0f49bc3a6..41d0e7c2f 100644
--- a/builtin/misc_helpers.lua
+++ b/builtin/misc_helpers.lua
@@ -184,6 +184,18 @@ function cleanup_path(temppath)
return temppath
end
+local tbl = engine or minetest
+function tbl.formspec_escape(text)
+ if text ~= nil then
+ text = string.gsub(text,"\\","\\\\")
+ text = string.gsub(text,"%]","\\]")
+ text = string.gsub(text,"%[","\\[")
+ text = string.gsub(text,";","\\;")
+ text = string.gsub(text,",","\\,")
+ end
+ return text
+end
+
--------------------------------------------------------------------------------
-- mainmenu only functions
--------------------------------------------------------------------------------
@@ -197,41 +209,7 @@ if engine ~= nil then
return nil
end
-
- --------------------------------------------------------------------------------
- function fs_escape_string(text)
- if text ~= nil then
- while (text:find("\r\n") ~= nil) do
- local newtext = text:sub(1,text:find("\r\n")-1)
- newtext = newtext .. " " .. text:sub(text:find("\r\n")+3)
-
- text = newtext
- end
-
- while (text:find("\n") ~= nil) do
- local newtext = text:sub(1,text:find("\n")-1)
- newtext = newtext .. " " .. text:sub(text:find("\n")+1)
-
- text = newtext
- end
-
- while (text:find("\r") ~= nil) do
- local newtext = text:sub(1,text:find("\r")-1)
- newtext = newtext .. " " .. text:sub(text:find("\r")+1)
-
- text = newtext
- end
-
- text = string.gsub(text,"\\","\\\\")
- text = string.gsub(text,"%]","\\]")
- text = string.gsub(text,"%[","\\[")
- text = string.gsub(text,";","\\;")
- text = string.gsub(text,",","\\,")
- end
- return text
- end
end
-
--------------------------------------------------------------------------------
-- core only fct
--------------------------------------------------------------------------------
@@ -241,3 +219,4 @@ if minetest ~= nil then
return "(" .. pos.x .. "," .. pos.y .. "," .. pos.z .. ")"
end
end
+