secure request for lua-utf8 library

This commit is contained in:
Andrey Stepanov 2025-01-12 19:34:39 +05:00
parent 3dd2c91bdc
commit 2cc854ee7c
Signed by: Koldun
GPG Key ID: 53DE683337F5D25F
2 changed files with 10 additions and 2 deletions

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