diff options
author | Erik Johnston <erik@matrix.org> | 2015-03-18 11:33:46 +0000 |
---|---|---|
committer | Erik Johnston <erik@matrix.org> | 2015-03-18 11:34:18 +0000 |
commit | f88db7ac0bc36974240db869606634b817471842 (patch) | |
tree | cdf1ba8ed785b6a53b2cc9de158bdfb429600737 /synapse/handlers/register.py | |
parent | Do more validation of incoming request (diff) | |
download | synapse-f88db7ac0bc36974240db869606634b817471842.tar.xz |
Factor out user id validation checks
Diffstat (limited to 'synapse/handlers/register.py')
-rw-r--r-- | synapse/handlers/register.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/synapse/handlers/register.py b/synapse/handlers/register.py index cda4a8502a..c25e321099 100644 --- a/synapse/handlers/register.py +++ b/synapse/handlers/register.py @@ -31,6 +31,7 @@ import base64 import bcrypt import json import logging +import urllib logger = logging.getLogger(__name__) @@ -63,6 +64,13 @@ class RegistrationHandler(BaseHandler): password_hash = bcrypt.hashpw(password, bcrypt.gensalt()) if localpart: + if localpart and urllib.quote(localpart) != localpart: + raise SynapseError( + 400, + "User ID must only contain characters which do not" + " require URL encoding." + ) + user = UserID(localpart, self.hs.hostname) user_id = user.to_string() |