mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-05-03 14:34:47 -04:00
Validate group ids when parsing
May as well do it whenever we parse a Group ID. We check the sigil and basic structure here so it makes sense to check the grammar in the same place.
This commit is contained in:
parent
29812c628b
commit
1135193dfd
3 changed files with 45 additions and 17 deletions
|
@ -161,6 +161,23 @@ class GroupID(DomainSpecificString):
|
|||
"""Structure representing a group ID."""
|
||||
SIGIL = "+"
|
||||
|
||||
@classmethod
|
||||
def from_string(cls, s):
|
||||
group_id = super(GroupID, cls).from_string(s)
|
||||
if not group_id.localpart:
|
||||
raise SynapseError(
|
||||
400,
|
||||
"Group ID cannot be empty",
|
||||
)
|
||||
|
||||
if contains_invalid_mxid_characters(group_id.localpart):
|
||||
raise SynapseError(
|
||||
400,
|
||||
"Group ID can only contain characters a-z, 0-9, or '=_-./'",
|
||||
)
|
||||
|
||||
return group_id
|
||||
|
||||
|
||||
mxid_localpart_allowed_characters = set("_-./=" + string.ascii_lowercase + string.digits)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue