mirror of https://github.com/zulip/zulip.git
users: Allow zero-width-joiners in user names.
Partially fixes: #20128.
This commit is contained in:
parent
58bc98afb5
commit
cec0942b4b
|
@ -23,6 +23,7 @@ from zerver.lib.exceptions import (
|
|||
OrganizationAdministratorRequiredError,
|
||||
OrganizationOwnerRequiredError,
|
||||
)
|
||||
from zerver.lib.string_validation import check_string_is_printable
|
||||
from zerver.lib.timestamp import timestamp_to_datetime
|
||||
from zerver.lib.timezone import canonicalize_timezone
|
||||
from zerver.lib.types import ProfileDataElementUpdateDict, ProfileDataElementValue, RawUserDict
|
||||
|
@ -59,9 +60,10 @@ def check_full_name(
|
|||
raise JsonableError(_("Name too long!"))
|
||||
if len(full_name) < UserProfile.MIN_NAME_LENGTH:
|
||||
raise JsonableError(_("Name too short!"))
|
||||
for character in full_name:
|
||||
if unicodedata.category(character)[0] == "C" or character in UserProfile.NAME_INVALID_CHARS:
|
||||
raise JsonableError(_("Invalid characters in name!"))
|
||||
if check_string_is_printable(full_name) is not None or any(
|
||||
character in full_name for character in UserProfile.NAME_INVALID_CHARS
|
||||
):
|
||||
raise JsonableError(_("Invalid characters in name!"))
|
||||
# Names ending with e.g. `|15` could be ambiguous for
|
||||
# sloppily-written parsers of our Markdown syntax for mentioning
|
||||
# users with ambiguous names, and likely have no real use, so we
|
||||
|
|
|
@ -125,6 +125,14 @@ class ChangeSettingsTest(ZulipTestCase):
|
|||
def test_illegal_characters_in_name_changes(self) -> None:
|
||||
self.login("hamlet")
|
||||
|
||||
# Make sure unicode works
|
||||
json_result = self.client_patch("/json/settings", dict(full_name="BLÅHAJ"))
|
||||
self.assert_json_success(json_result)
|
||||
|
||||
# Make sure zero-width-joiners work
|
||||
json_result = self.client_patch("/json/settings", dict(full_name="BLÅHAJ 🏳️⚧️"))
|
||||
self.assert_json_success(json_result)
|
||||
|
||||
# Now try a name with invalid characters
|
||||
json_result = self.client_patch("/json/settings", dict(full_name="Opheli*"))
|
||||
self.assert_json_error(json_result, "Invalid characters in name!")
|
||||
|
|
Loading…
Reference in New Issue