summaryrefslogtreecommitdiff
path: root/internal.lua
diff options
context:
space:
mode:
authorShadowNinja <shadowninja@minetest.net>2013-12-21 12:26:37 -0500
committerShadowNinja <shadowninja@minetest.net>2013-12-21 12:26:37 -0500
commitb69fc35c888c569bf7e87e24466740ca5f749918 (patch)
treecc62c43de43a8d94b297c89a46f859dc486f90ff /internal.lua
parentd30b33ba24e52d7299119013894ae97523558f78 (diff)
Allow Lua regexs in search, and check for bad ones
Diffstat (limited to 'internal.lua')
-rw-r--r--internal.lua11
1 files changed, 3 insertions, 8 deletions
diff --git a/internal.lua b/internal.lua
index 6d7c464..daf8f4b 100644
--- a/internal.lua
+++ b/internal.lua
@@ -92,14 +92,9 @@ function unified_inventory.apply_filter(player, filter)
local player_name = player:get_player_name()
local size = 0
local lfilter = string.lower(filter)
- if lfilter ~= "" then
- for c in lfilter:gmatch(".") do
- if c == '[' or c == ']' or c == '{' or c == '}' or
- c == '(' or c == ')' or c == '%' then
- lfilter = ""
- break
- end
- end
+ if not pcall(function() ("technic:test"):find(lfilter) end) then
+ -- Filter is invalid
+ lfilter = ""
end
unified_inventory.filtered_items_list[player_name]={}
for name, def in pairs(minetest.registered_items) do