diff options
author | Erik Johnston <erikj@jki.re> | 2018-10-25 17:04:59 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-10-25 17:04:59 +0100 |
commit | c85e063302243d2c82da6e709cf1e93b5b3085e9 (patch) | |
tree | 05bde2fb78f07141bda83d0a4fa54f08c19ec55c /synapse/federation/federation_server.py | |
parent | Merge pull request #4081 from matrix-org/neilj/fix_mau_init (diff) | |
parent | Merge branch 'develop' of github.com:matrix-org/synapse into erikj/alias_disa... (diff) | |
download | synapse-c85e063302243d2c82da6e709cf1e93b5b3085e9.tar.xz |
Merge pull request #4051 from matrix-org/erikj/alias_disallow_list
Add config option to control alias creation
Diffstat (limited to 'synapse/federation/federation_server.py')
-rw-r--r-- | synapse/federation/federation_server.py | 16 |
1 files changed, 2 insertions, 14 deletions
diff --git a/synapse/federation/federation_server.py b/synapse/federation/federation_server.py index af0107a46e..0f9302a6a8 100644 --- a/synapse/federation/federation_server.py +++ b/synapse/federation/federation_server.py @@ -14,7 +14,6 @@ # See the License for the specific language governing permissions and # limitations under the License. import logging -import re import six from six import iteritems @@ -44,6 +43,7 @@ from synapse.replication.http.federation import ( ReplicationGetQueryRestServlet, ) from synapse.types import get_domain_from_id +from synapse.util import glob_to_regex from synapse.util.async_helpers import Linearizer, concurrently_execute from synapse.util.caches.response_cache import ResponseCache from synapse.util.logcontext import nested_logging_context @@ -729,22 +729,10 @@ def _acl_entry_matches(server_name, acl_entry): if not isinstance(acl_entry, six.string_types): logger.warn("Ignoring non-str ACL entry '%s' (is %s)", acl_entry, type(acl_entry)) return False - regex = _glob_to_regex(acl_entry) + regex = glob_to_regex(acl_entry) return regex.match(server_name) -def _glob_to_regex(glob): - res = '' - for c in glob: - if c == '*': - res = res + '.*' - elif c == '?': - res = res + '.' - else: - res = res + re.escape(c) - return re.compile(res + "\\Z", re.IGNORECASE) - - class FederationHandlerRegistry(object): """Allows classes to register themselves as handlers for a given EDU or query type for incoming federation traffic. |