From 39a255375ef23c6df845bf50b28c88ef4ff8eb3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tristan=20Mah=C3=A9?= Date: Thu, 1 Nov 2018 13:14:37 -0700 Subject: [PATCH] use urllib.parse.urlsplit instead of regex --- relay/actor.py | 4 ++-- relay/database.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/relay/actor.py b/relay/actor.py index 49abc38..8ddcf0e 100644 --- a/relay/actor.py +++ b/relay/actor.py @@ -3,9 +3,9 @@ import aiohttp.web import asyncio import logging import uuid +import re import urllib.parse import simplejson as json -import re import cgi from Crypto.PublicKey import RSA from .database import DATABASE @@ -186,7 +186,7 @@ async def handle_follow(actor, data, request): following = DATABASE.get('relay-list', []) inbox = get_actor_inbox(actor) - if re.search('https://(.*)/inbox',inbox).group(1) in AP_CONFIG['blocked_instances']: + if urllib.parse.urlsplit(inbox).hostname in AP_CONFIG['blocked_instances']: return if inbox not in following: diff --git a/relay/database.py b/relay/database.py index 444d4b8..0d171a0 100644 --- a/relay/database.py +++ b/relay/database.py @@ -1,6 +1,6 @@ import asyncio import logging -import re +import urllib.parse import simplejson as json @@ -16,7 +16,7 @@ except: following = DATABASE.get('relay-list', []) for inbox in following: - if re.search('https://(.*)/inbox',inbox).group(1) in CONFIG['ap']['blocked_instances']: + if urllib.parse.urlsplit(inbox).hostname in CONFIG['ap']['blocked_instances']: following.remove(inbox) DATABASE['relay-list'] = following