Fix crash when searching for "["

This commit is contained in:
Wuzzy 2024-11-02 12:06:37 +01:00
parent b03c1451ca
commit a37f44dbce

View File

@ -127,13 +127,13 @@ local collect_items = function(filter, lang_code)
-- First, try to match original description -- First, try to match original description
if desc ~= "" then if desc ~= "" then
local ldesc = string.lower(desc) local ldesc = string.lower(desc)
matches = string.match(ldesc, filter) ~= nil matches = string.find(ldesc, filter, 1, true) ~= nil
-- Second, try to match translated description -- Second, try to match translated description
if not matches then if not matches then
local tdesc = minetest.get_translated_string(lang_code, desc) local tdesc = minetest.get_translated_string(lang_code, desc)
if tdesc ~= "" then if tdesc ~= "" then
tdesc = string.lower(tdesc) tdesc = string.lower(tdesc)
matches = string.match(tdesc, filter) ~= nil matches = string.find(tdesc, filter, 1, true) ~= nil
end end
end end
-- Third, try to match translated short description -- Third, try to match translated short description
@ -142,14 +142,14 @@ local collect_items = function(filter, lang_code)
if sdesc ~= "" then if sdesc ~= "" then
sdesc = minetest.get_translated_string(lang_code, sdesc) sdesc = minetest.get_translated_string(lang_code, sdesc)
sdesc = string.lower(sdesc) sdesc = string.lower(sdesc)
matches = string.match(sdesc, filter) ~= nil matches = string.find(sdesc, filter, 1, true) ~= nil
end end
end end
end end
-- Fourth, try to match itemstring -- Fourth, try to match itemstring
if not matches then if not matches then
matches = string.match(itemstring, filter) ~= nil matches = string.find(itemstring, filter, 1, true) ~= nil
end end
-- If item was matched, add to item list -- If item was matched, add to item list