secure request for lua-utf8 library
This commit is contained in:
parent
3dd2c91bdc
commit
2cc854ee7c
10
init.lua
10
init.lua
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user