summary refs log tree commit diff
path: root/synapse/rest
diff options
context:
space:
mode:
authorBrendan Abolivier <babolivier@matrix.org>2022-03-31 11:49:49 +0200
committerGitHub <noreply@github.com>2022-03-31 11:49:49 +0200
commitf96b85eca8cf14530f26b678dbb4900c54fb6a59 (patch)
treef1192d39b2cc01889a6a4ae2d0de5a6ffe9c70e2 /synapse/rest
parentRemove the unused and unstable `/aggregations` endpoint. (#12293) (diff)
downloadsynapse-f96b85eca8cf14530f26b678dbb4900c54fb6a59.tar.xz
Ensure the type of URL attributes is always str when matching against preview blacklist (#12333)
Diffstat (limited to 'synapse/rest')
-rw-r--r--synapse/rest/media/v1/preview_url_resource.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/synapse/rest/media/v1/preview_url_resource.py b/synapse/rest/media/v1/preview_url_resource.py
index d47af8ead6..50383bdbd1 100644
--- a/synapse/rest/media/v1/preview_url_resource.py
+++ b/synapse/rest/media/v1/preview_url_resource.py
@@ -200,12 +200,17 @@ class PreviewUrlResource(DirectServeJsonResource):
                     match = False
                     continue
 
+                # Some attributes might not be parsed as strings by urlsplit (such as the
+                # port, which is parsed as an int). Because we use match functions that
+                # expect strings, we want to make sure that's what we give them.
+                value_str = str(value)
+
                 if pattern.startswith("^"):
-                    if not re.match(pattern, getattr(url_tuple, attrib)):
+                    if not re.match(pattern, value_str):
                         match = False
                         continue
                 else:
-                    if not fnmatch.fnmatch(getattr(url_tuple, attrib), pattern):
+                    if not fnmatch.fnmatch(value_str, pattern):
                         match = False
                         continue
             if match: