mirror of
https://github.com/ShadowNinja/name_restrictions.git
synced 2024-12-22 16:40:20 +01:00
Strip whitespace-like characters from names before checking them for similarity
Previously, these characters whern't considered when checking for conflicts, but they weren't removed -- meaning that a player named "foo_" would prevent a player named "foo" from logging in, but not the other way around.
This commit is contained in:
parent
75b96c7cf9
commit
1e6d9e01b7
8
init.lua
8
init.lua
@ -131,8 +131,14 @@ all_chars = all_chars .. "]"
|
||||
minetest.register_on_prejoinplayer(function(name, ip)
|
||||
if exemptions[name] then return end
|
||||
|
||||
-- String off dashes and underscores from the start and end of the name.
|
||||
local stripped_name = name:match("^[_-]*(.-)[_-]*$")
|
||||
if not stripped_name or stripped_name == "" then
|
||||
return "Your name is composed solely of whitespace-like characters."
|
||||
end
|
||||
|
||||
-- Generate a regular expression to match all similar names
|
||||
local re = name:gsub(all_chars, char_map)
|
||||
local re = stripped_name:gsub(all_chars, char_map)
|
||||
re = "^[_-]*" .. re .. "[_-]*$"
|
||||
|
||||
for authName, _ in pairs(minetest.auth_table) do
|
||||
|
Loading…
Reference in New Issue
Block a user