@@ -348,22 +348,15 @@ class EventID(DomainSpecificString):
348348 SIGIL = "$"
349349
350350
351- mxid_localpart_allowed_characters = set (
352- "_-./=" + string .ascii_lowercase + string .digits
351+ MXID_LOCALPART_ALLOWED_CHARACTERS = set (
352+ "_-./=+ " + string .ascii_lowercase + string .digits
353353)
354- # MSC4007 adds the + to the allowed characters.
355- #
356- # TODO If this was accepted, update the SSO code to support this, see the callers
357- # of map_username_to_mxid_localpart.
358- extended_mxid_localpart_allowed_characters = mxid_localpart_allowed_characters | {"+" }
359354
360355# Guest user IDs are purely numeric.
361356GUEST_USER_ID_PATTERN = re .compile (r"^\d+$" )
362357
363358
364- def contains_invalid_mxid_characters (
365- localpart : str , use_extended_character_set : bool
366- ) -> bool :
359+ def contains_invalid_mxid_characters (localpart : str ) -> bool :
367360 """Check for characters not allowed in an mxid or groupid localpart
368361
369362 Args:
@@ -374,12 +367,7 @@ def contains_invalid_mxid_characters(
374367 Returns:
375368 True if there are any naughty characters
376369 """
377- allowed_characters = (
378- extended_mxid_localpart_allowed_characters
379- if use_extended_character_set
380- else mxid_localpart_allowed_characters
381- )
382- return any (c not in allowed_characters for c in localpart )
370+ return any (c not in MXID_LOCALPART_ALLOWED_CHARACTERS for c in localpart )
383371
384372
385373UPPER_CASE_PATTERN = re .compile (b"[A-Z_]" )
@@ -396,7 +384,7 @@ def contains_invalid_mxid_characters(
396384# bytes rather than strings
397385#
398386NON_MXID_CHARACTER_PATTERN = re .compile (
399- ("[^%s]" % (re .escape ("" .join (mxid_localpart_allowed_characters - {"=" })),)).encode (
387+ ("[^%s]" % (re .escape ("" .join (MXID_LOCALPART_ALLOWED_CHARACTERS - {"=" })),)).encode (
400388 "ascii"
401389 )
402390)
0 commit comments