#1445 #1709 - Latinify character names in .create()

This commit is contained in:
trhr 2020-04-05 23:54:10 -05:00
parent fda51edea6
commit f95dd3f2aa

View file

@ -2065,6 +2065,7 @@ class DefaultCharacter(DefaultObject):
# Set the supplied key as the name of the intended object
kwargs["key"] = key
key = cls._validate(key)
# Get home for character
kwargs["home"] = ObjectDB.objects.get_id(kwargs.get("home", settings.DEFAULT_HOME))
@ -2115,6 +2116,22 @@ class DefaultCharacter(DefaultObject):
return obj, errors
def _validate(self, key):
"""
Validate that character name is acceptable prior to creating. Note that this should be refactored
to support i18n for non-latin scripts, but as we (currently) have no bug reports requesting better
support of non-latin character sets, requiring character names to be latinified is an acceptable option.
Args:
key (str) : The name of the character
Returns:
key (str) : A valid name.
"""
from evennia.utils.utils import latinify
key = latinify(key, default="X")
return key
def basetype_setup(self):
"""
Setup character-specific security.