Change lowercase detection to work with CJK languages

str.islower() does not properly work with characters in the Lo category
so CJK languages fail the check.

Fix #7698
This commit is contained in:
Rapptz 2022-03-15 23:37:43 -04:00
parent fd5dea4e34
commit 446c502995

View File

@ -142,7 +142,12 @@ def validate_name(name: str) -> str:
match = VALID_SLASH_COMMAND_NAME.match(name)
if match is None:
raise ValueError('names must be between 1-32 characters')
if not name.islower():
# Ideally, name.islower() would work instead but since certain characters
# are Lo (e.g. CJK) those don't pass the test. I'd use `casefold` instead as
# well, but chances are the server-side check is probably something similar to
# this code anyway.
if name.lower() != name:
raise ValueError('names must be all lower case')
return name