aboutsummaryrefslogtreecommitdiff
path: root/builtin
diff options
context:
space:
mode:
Diffstat (limited to 'builtin')
-rw-r--r--builtin/mainmenu.lua12
-rw-r--r--builtin/misc.lua7
-rw-r--r--builtin/misc_helpers.lua47
-rw-r--r--builtin/modstore.lua4
4 files changed, 21 insertions, 49 deletions
diff --git a/builtin/mainmenu.lua b/builtin/mainmenu.lua
index 926f3f2d9..5eb1a73db 100644
--- a/builtin/mainmenu.lua
+++ b/builtin/mainmenu.lua
@@ -39,11 +39,11 @@ function menu.render_favorite(spec,render_details)
local text = ""
if spec.name ~= nil then
- text = text .. fs_escape_string(spec.name:trim())
+ text = text .. engine.formspec_escape(spec.name:trim())
-- if spec.description ~= nil and
--- fs_escape_string(spec.description):trim() ~= "" then
--- text = text .. " (" .. fs_escape_string(spec.description) .. ")"
+-- engine.formspec_escape(spec.description):trim() ~= "" then
+-- text = text .. " (" .. engine.formspec_escape(spec.description) .. ")"
-- end
else
if spec.address ~= nil then
@@ -93,7 +93,7 @@ function menu.render_favorite(spec,render_details)
string.format("%03d",spec.clients_max) .. " "
end
- return playercount .. fs_escape_string(details) .. text
+ return playercount .. engine.formspec_escape(details) .. text
end
--------------------------------------------------------------------------------
@@ -900,7 +900,7 @@ function tabbuilder.tab_multiplayer()
if menu.fav_selected ~= nil and
menu.favorites[menu.fav_selected].description ~= nil then
retval = retval ..
- fs_escape_string(menu.favorites[menu.fav_selected].description,true)
+ engine.formspec_escape(menu.favorites[menu.fav_selected].description,true)
end
retval = retval ..
@@ -1040,7 +1040,7 @@ function tabbuilder.tab_TP()
menu.render_TP_list(TPlist) ..
";" .. index .. "]" ..
"image[0.65,0.25;4.0,3.7;"..(menu.TPscreen or no_screenshot).."]"..
- "textarea[1.0,3.25;3.7,1.5;;"..(menu.TPinfo or "")..";]"
+ "textarea[1.0,3.25;3.7,1.5;;"..engine.formspec_escape(menu.TPinfo or "")..";]"
end
--------------------------------------------------------------------------------
diff --git a/builtin/misc.lua b/builtin/misc.lua
index f4e7dbca6..82a0ba298 100644
--- a/builtin/misc.lua
+++ b/builtin/misc.lua
@@ -99,10 +99,3 @@ function minetest.setting_get_pos(name)
return minetest.string_to_pos(value)
end
-function minetest.formspec_escape(str)
- str = string.gsub(str, "\\", "\\\\")
- str = string.gsub(str, "%[", "\\[")
- str = string.gsub(str, "%]", "\\]")
- return str
-end
-
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
+
diff --git a/builtin/modstore.lua b/builtin/modstore.lua
index 6d761d47c..e94c174c2 100644
--- a/builtin/modstore.lua
+++ b/builtin/modstore.lua
@@ -233,12 +233,12 @@ function modstore.getmodlist(list)
--title + author
retval = retval .."label[2.75," .. screenshot_ypos .. ";" ..
- fs_escape_string(details.title) .. " (" .. details.author .. ")]"
+ engine.formspec_escape(details.title) .. " (" .. details.author .. ")]"
--description
local descriptiony = screenshot_ypos + 0.5
retval = retval .. "textarea[3," .. descriptiony .. ";6.5,1.55;;" ..
- fs_escape_string(details.description) .. ";]"
+ engine.formspec_escape(details.description) .. ";]"
--rating
local ratingy = screenshot_ypos + 0.6
retval = retval .."label[10.1," .. ratingy .. ";Rating: " .. details.rating .."]"