Snake case

merge-requests/30/head
Bob Mottram 2021-12-27 20:47:05 +00:00
parent 5ce15ffbed
commit 602ab1ad58
10 changed files with 27 additions and 27 deletions

View File

@ -11,7 +11,7 @@ import os
from utils import has_object_string_object from utils import has_object_string_object
from utils import has_users_path from utils import has_users_path
from utils import get_full_domain from utils import get_full_domain
from utils import urlPermitted from utils import url_permitted
from utils import get_domain_from_actor from utils import get_domain_from_actor
from utils import getNicknameFromActor from utils import getNicknameFromActor
from utils import domain_permitted from utils import domain_permitted
@ -36,7 +36,7 @@ def _create_accept_reject(base_dir: str, federation_list: [],
if not objectJson.get('actor'): if not objectJson.get('actor'):
return None return None
if not urlPermitted(objectJson['actor'], federation_list): if not url_permitted(objectJson['actor'], federation_list):
return None return None
domain = get_full_domain(domain, port) domain = get_full_domain(domain, port)

View File

@ -15,7 +15,7 @@ from utils import has_users_path
from utils import get_full_domain from utils import get_full_domain
from utils import get_status_number from utils import get_status_number
from utils import create_outbox_dir from utils import create_outbox_dir
from utils import urlPermitted from utils import url_permitted
from utils import getNicknameFromActor from utils import getNicknameFromActor
from utils import get_domain_from_actor from utils import get_domain_from_actor
from utils import locate_post from utils import locate_post
@ -131,7 +131,7 @@ def createAnnounce(session, base_dir: str, federation_list: [],
followers url objectUrl is typically the url of the message, followers url objectUrl is typically the url of the message,
corresponding to url or atomUri in createPostBase corresponding to url or atomUri in createPostBase
""" """
if not urlPermitted(objectUrl, federation_list): if not url_permitted(objectUrl, federation_list):
return None return None
domain = remove_domain_port(domain) domain = remove_domain_port(domain)

View File

@ -16,7 +16,7 @@ from utils import has_users_path
from utils import get_full_domain from utils import get_full_domain
from utils import remove_id_ending from utils import remove_id_ending
from utils import remove_post_from_cache from utils import remove_post_from_cache
from utils import urlPermitted from utils import url_permitted
from utils import getNicknameFromActor from utils import getNicknameFromActor
from utils import get_domain_from_actor from utils import get_domain_from_actor
from utils import locate_post from utils import locate_post
@ -264,7 +264,7 @@ def bookmark(recent_posts_cache: {},
'to' might be a specific person (actor) whose post was bookmarked 'to' might be a specific person (actor) whose post was bookmarked
object is typically the url of the message which was bookmarked object is typically the url of the message which was bookmarked
""" """
if not urlPermitted(objectUrl, federation_list): if not url_permitted(objectUrl, federation_list):
return None return None
fullDomain = get_full_domain(domain, port) fullDomain = get_full_domain(domain, port)
@ -324,7 +324,7 @@ def undoBookmark(recent_posts_cache: {},
'to' might be a specific person (actor) whose post was bookmarked 'to' might be a specific person (actor) whose post was bookmarked
object is typically the url of the message which was bookmarked object is typically the url of the message which was bookmarked
""" """
if not urlPermitted(objectUrl, federation_list): if not url_permitted(objectUrl, federation_list):
return None return None
fullDomain = get_full_domain(domain, port) fullDomain = get_full_domain(domain, port)

View File

@ -296,7 +296,7 @@ from utils import remove_post_from_cache
from utils import getNicknameFromActor from utils import getNicknameFromActor
from utils import get_domain_from_actor from utils import get_domain_from_actor
from utils import get_status_number from utils import get_status_number
from utils import urlPermitted from utils import url_permitted
from utils import load_json from utils import load_json
from utils import save_json from utils import save_json
from utils import is_suspended from utils import is_suspended
@ -722,7 +722,7 @@ class PubServer(BaseHTTPRequestHandler):
return False return False
# is the keyId (actor) valid? # is the keyId (actor) valid?
if not urlPermitted(keyId, self.server.federation_list): if not url_permitted(keyId, self.server.federation_list):
if self.server.debug: if self.server.debug:
print('AUTH: Secure mode GET request not permitted: ' + keyId) print('AUTH: Secure mode GET request not permitted: ' + keyId)
return False return False

View File

@ -46,7 +46,7 @@ from utils import remove_avatar_from_cache
from utils import isPublicPost from utils import isPublicPost
from utils import get_cached_post_filename from utils import get_cached_post_filename
from utils import remove_post_from_cache from utils import remove_post_from_cache
from utils import urlPermitted from utils import url_permitted
from utils import create_inbox_queue_dir from utils import create_inbox_queue_dir
from utils import get_status_number from utils import get_status_number
from utils import get_domain_from_actor from utils import get_domain_from_actor
@ -430,7 +430,7 @@ def inboxPermittedMessage(domain: str, message_json: {},
if domain in actor: if domain in actor:
return True return True
if not urlPermitted(actor, federation_list): if not url_permitted(actor, federation_list):
return False return False
alwaysAllowedTypes = ( alwaysAllowedTypes = (
@ -443,7 +443,7 @@ def inboxPermittedMessage(domain: str, message_json: {},
inReplyTo = message_json['object']['inReplyTo'] inReplyTo = message_json['object']['inReplyTo']
if not isinstance(inReplyTo, str): if not isinstance(inReplyTo, str):
return False return False
if not urlPermitted(inReplyTo, federation_list): if not url_permitted(inReplyTo, federation_list):
return False return False
return True return True

View File

@ -17,7 +17,7 @@ from utils import has_object_dict
from utils import has_users_path from utils import has_users_path
from utils import get_full_domain from utils import get_full_domain
from utils import remove_id_ending from utils import remove_id_ending
from utils import urlPermitted from utils import url_permitted
from utils import getNicknameFromActor from utils import getNicknameFromActor
from utils import get_domain_from_actor from utils import get_domain_from_actor
from utils import locate_post from utils import locate_post
@ -83,7 +83,7 @@ def _like(recent_posts_cache: {},
'to' might be a specific person (actor) whose post was liked 'to' might be a specific person (actor) whose post was liked
object is typically the url of the message which was liked object is typically the url of the message which was liked
""" """
if not urlPermitted(objectUrl, federation_list): if not url_permitted(objectUrl, federation_list):
return None return None
fullDomain = get_full_domain(domain, port) fullDomain = get_full_domain(domain, port)

View File

@ -53,7 +53,7 @@ from utils import get_followers_list
from utils import is_evil from utils import is_evil
from utils import get_status_number from utils import get_status_number
from utils import create_person_dir from utils import create_person_dir
from utils import urlPermitted from utils import url_permitted
from utils import getNicknameFromActor from utils import getNicknameFromActor
from utils import get_domain_from_actor from utils import get_domain_from_actor
from utils import deletePost from utils import deletePost
@ -610,8 +610,8 @@ def _getPosts(session, outboxUrl: str, maxPosts: int,
if tagItem.get('name') and tagItem.get('icon'): if tagItem.get('name') and tagItem.get('icon'):
if tagItem['icon'].get('url'): if tagItem['icon'].get('url'):
# No emoji from non-permitted domains # No emoji from non-permitted domains
if urlPermitted(tagItem['icon']['url'], if url_permitted(tagItem['icon']['url'],
federation_list): federation_list):
emojiName = tagItem['name'] emojiName = tagItem['name']
emojiIcon = tagItem['icon']['url'] emojiIcon = tagItem['icon']['url']
emoji[emojiName] = emojiIcon emoji[emojiName] = emojiIcon
@ -640,8 +640,8 @@ def _getPosts(session, outboxUrl: str, maxPosts: int,
if thisItem['inReplyTo']: if thisItem['inReplyTo']:
if isinstance(thisItem['inReplyTo'], str): if isinstance(thisItem['inReplyTo'], str):
# No replies to non-permitted domains # No replies to non-permitted domains
if not urlPermitted(thisItem['inReplyTo'], if not url_permitted(thisItem['inReplyTo'],
federation_list): federation_list):
if debug: if debug:
print('url not permitted ' + print('url not permitted ' +
thisItem['inReplyTo']) thisItem['inReplyTo'])
@ -653,8 +653,8 @@ def _getPosts(session, outboxUrl: str, maxPosts: int,
for attach in thisItem['attachment']: for attach in thisItem['attachment']:
if attach.get('name') and attach.get('url'): if attach.get('name') and attach.get('url'):
# no attachments from non-permitted domains # no attachments from non-permitted domains
if urlPermitted(attach['url'], if url_permitted(attach['url'],
federation_list): federation_list):
attachment.append([attach['name'], attachment.append([attach['name'],
attach['url']]) attach['url']])
else: else:

View File

@ -19,7 +19,7 @@ from utils import has_object_dict
from utils import has_users_path from utils import has_users_path
from utils import get_full_domain from utils import get_full_domain
from utils import remove_id_ending from utils import remove_id_ending
from utils import urlPermitted from utils import url_permitted
from utils import getNicknameFromActor from utils import getNicknameFromActor
from utils import get_domain_from_actor from utils import get_domain_from_actor
from utils import locate_post from utils import locate_post
@ -76,7 +76,7 @@ def _reaction(recent_posts_cache: {},
'to' might be a specific person (actor) whose post was reaction 'to' might be a specific person (actor) whose post was reaction
object is typically the url of the message which was reaction object is typically the url of the message which was reaction
""" """
if not urlPermitted(objectUrl, federation_list): if not url_permitted(objectUrl, federation_list):
return None return None
if not validEmojiContent(emojiContent): if not validEmojiContent(emojiContent):
print('_reaction: Invalid emoji reaction: "' + emojiContent + '"') print('_reaction: Invalid emoji reaction: "' + emojiContent + '"')

View File

@ -9,7 +9,7 @@ __module_group__ = "Session"
import os import os
import requests import requests
from utils import urlPermitted from utils import url_permitted
from utils import is_image_file from utils import is_image_file
from httpsig import createSignedHeader from httpsig import createSignedHeader
import json import json
@ -297,7 +297,7 @@ def postJson(http_prefix: str, domain_full: str,
"""Post a json message to the inbox of another person """Post a json message to the inbox of another person
""" """
# check that we are posting to a permitted domain # check that we are posting to a permitted domain
if not urlPermitted(inboxUrl, federation_list): if not url_permitted(inboxUrl, federation_list):
if not quiet: if not quiet:
print('postJson: ' + inboxUrl + ' not permitted') print('postJson: ' + inboxUrl + ' not permitted')
return None return None
@ -394,7 +394,7 @@ def postImage(session, attachImageFilename: str, federation_list: [],
"""Post an image to the inbox of another person or outbox via c2s """Post an image to the inbox of another person or outbox via c2s
""" """
# check that we are posting to a permitted domain # check that we are posting to a permitted domain
if not urlPermitted(inboxUrl, federation_list): if not url_permitted(inboxUrl, federation_list):
print('postJson: ' + inboxUrl + ' not permitted') print('postJson: ' + inboxUrl + ' not permitted')
return None return None

View File

@ -823,7 +823,7 @@ def domain_permitted(domain: str, federation_list: []) -> bool:
return False return False
def urlPermitted(url: str, federation_list: []): def url_permitted(url: str, federation_list: []):
if is_evil(url): if is_evil(url):
return False return False
if not federation_list: if not federation_list: