use urllib.parse.urlsplit instead of regex
This commit is contained in:
parent
fb669f124f
commit
39a255375e
|
@ -3,9 +3,9 @@ import aiohttp.web
|
||||||
import asyncio
|
import asyncio
|
||||||
import logging
|
import logging
|
||||||
import uuid
|
import uuid
|
||||||
|
import re
|
||||||
import urllib.parse
|
import urllib.parse
|
||||||
import simplejson as json
|
import simplejson as json
|
||||||
import re
|
|
||||||
import cgi
|
import cgi
|
||||||
from Crypto.PublicKey import RSA
|
from Crypto.PublicKey import RSA
|
||||||
from .database import DATABASE
|
from .database import DATABASE
|
||||||
|
@ -186,7 +186,7 @@ async def handle_follow(actor, data, request):
|
||||||
following = DATABASE.get('relay-list', [])
|
following = DATABASE.get('relay-list', [])
|
||||||
inbox = get_actor_inbox(actor)
|
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
|
return
|
||||||
|
|
||||||
if inbox not in following:
|
if inbox not in following:
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import asyncio
|
import asyncio
|
||||||
import logging
|
import logging
|
||||||
import re
|
import urllib.parse
|
||||||
import simplejson as json
|
import simplejson as json
|
||||||
|
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@ except:
|
||||||
|
|
||||||
following = DATABASE.get('relay-list', [])
|
following = DATABASE.get('relay-list', [])
|
||||||
for inbox in following:
|
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)
|
following.remove(inbox)
|
||||||
DATABASE['relay-list'] = following
|
DATABASE['relay-list'] = following
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue