summary refs log tree commit diff
diff options
context:
space:
mode:
authorRichard van der Hoff <1389908+richvdh@users.noreply.github.com>2018-04-04 12:08:29 +0100
committerGitHub <noreply@github.com>2018-04-04 12:08:29 +0100
commitf92963f5db236c1afb2a489a44c9afdae7d61edc (patch)
treeff97601ef3557d10b4540cba79d919ba8bd099aa
parentMerge pull request #3000 from NotAFile/change-except-style (diff)
downloadsynapse-f92963f5db236c1afb2a489a44c9afdae7d61edc.tar.xz
Revert "improve mxid check performance"
-rw-r--r--synapse/types.py7
1 files changed, 3 insertions, 4 deletions
diff --git a/synapse/types.py b/synapse/types.py
index f1f41ccf90..7cb24cecb2 100644
--- a/synapse/types.py
+++ b/synapse/types.py
@@ -12,11 +12,11 @@
 # 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
 
 from collections import namedtuple
-import re
 
 
 class Requester(namedtuple("Requester", [
@@ -214,8 +214,7 @@ class GroupID(DomainSpecificString):
         return group_id
 
 
-# A regex that matches any valid mxid characters
-MXID_LOCALPART_REGEX = re.compile("^[_\-./=a-z0-9]*$")
+mxid_localpart_allowed_characters = set("_-./=" + string.ascii_lowercase + string.digits)
 
 
 def contains_invalid_mxid_characters(localpart):
@@ -227,7 +226,7 @@ def contains_invalid_mxid_characters(localpart):
     Returns:
         bool: True if there are any naughty characters
     """
-    return not MXID_LOCALPART_REGEX.match(localpart)
+    return any(c not in mxid_localpart_allowed_characters for c in localpart)
 
 
 class StreamToken(