Безопасное обращение к библиотеке lua-utf8 #3

Merged
Reload merged 1 commits from security into devel 2025-01-13 08:59:11 +03:00
2 changed files with 10 additions and 2 deletions
Showing only changes of commit 2cc854ee7c - Show all commits

View File

@ -28,7 +28,13 @@
local S = minetest.get_translator("filter")
filter = { registered_on_violations = {} }
local utf8 = require 'lua-utf8'
local ie = core.request_insecure_environment()
local str = nil
if ie then
str = ie.require("lua-utf8")
else
str = string
end
local words = {}
local muted = {}
local violations = {}
@ -66,7 +72,7 @@ end
function filter.check_message(name, message)
for _, w in ipairs(words) do
if utf8.find(utf8.lower(message), "%f[%a]" .. w .. "%f[%A]") then
if str.find(str.lower(message), "%f[%a]" .. w .. "%f[%A]") then
return false
end
end

View File

@ -13,6 +13,8 @@ muted for 1 minute. After that, their `shout` privilege is restored.
If they leave, their `shout` privilege is still restored, but only after
the time expires, not before.
Add this mod to `secure.trusted_mods` to allow filtering utf8 lines.
## API
### Callbacks