mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-05-16 16:42:17 -04:00
Ensure the type of URL attributes is always str when matching against preview blacklist (#12333)
This commit is contained in:
parent
c31c1091d4
commit
f96b85eca8
3 changed files with 49 additions and 4 deletions
|
@ -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:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue