mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-05-06 14:24:58 -04:00
Disallow capital letters in userids
Factor out a common function for checking user ids and group ids, which forbids capitals.
This commit is contained in:
parent
b4a6b7f720
commit
58fbbe0f1d
3 changed files with 26 additions and 17 deletions
|
@ -12,6 +12,7 @@
|
|||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
import string
|
||||
|
||||
from synapse.api.errors import SynapseError
|
||||
|
||||
|
@ -161,6 +162,21 @@ class GroupID(DomainSpecificString):
|
|||
SIGIL = "+"
|
||||
|
||||
|
||||
mxid_localpart_allowed_characters = set("_-./" + string.ascii_lowercase + string.digits)
|
||||
|
||||
|
||||
def contains_invalid_mxid_characters(localpart):
|
||||
"""Check for characters not allowed in an mxid or groupid localpart
|
||||
|
||||
Args:
|
||||
localpart (basestring): the localpart to be checked
|
||||
|
||||
Returns:
|
||||
bool: True if there are any naughty characters
|
||||
"""
|
||||
return any(c not in mxid_localpart_allowed_characters for c in localpart)
|
||||
|
||||
|
||||
class StreamToken(
|
||||
namedtuple("Token", (
|
||||
"room_key",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue