From 6f1f43dcf7b9f7458d874c88c37723606549ca4a Mon Sep 17 00:00:00 2001 From: Etoh Date: Tue, 21 Feb 2023 23:11:42 +0000 Subject: [PATCH] Add wildcard matching of trusted subdomains (#587) --- syncplay/client.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/syncplay/client.py b/syncplay/client.py index 0ec266e..8b2a303 100755 --- a/syncplay/client.py +++ b/syncplay/client.py @@ -569,8 +569,15 @@ class SyncplayClient(object): if self._config['trustedDomains']: for entry in self._config['trustedDomains']: trustedDomain, _, path = entry.partition('/') - if o.hostname not in (trustedDomain, "www." + trustedDomain): - # domain does not match + foundMatch = False + if o.hostname in (trustedDomain, "www." + trustedDomain): + foundMatch = True + elif "*" in trustedDomain: + wildcardRegex = "^("+re.escape(trustedDomain).replace("\\*","([^.]+)")+")$" + wildcardMatch = bool(re.fullmatch(wildcardRegex, o.hostname, re.IGNORECASE)) + if wildcardMatch: + foundMatch = True + if not foundMatch: continue if path and not o.path.startswith('/' + path): # trusted domain has a path component and it does not match