From c6b002652be61d8edee8c9648213419f401a0070 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Sun, 1 Mar 2020 10:18:08 +0000 Subject: [PATCH] Check that ports are digits --- manualapprove.py | 4 +++- skills.py | 5 ++++- webfinger.py | 4 +++- webinterface.py | 4 +++- 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/manualapprove.py b/manualapprove.py index 8bc98e5eb..f79c5e425 100644 --- a/manualapprove.py +++ b/manualapprove.py @@ -109,7 +109,9 @@ def manualApproveFollowRequest(session,baseDir: str, \ handleOfFollowRequester=handleOfFollowRequester.replace('\n','') port2=port if ':' in handleOfFollowRequester: - port2=int(handleOfFollowRequester.split(':')[1]) + port2Str=handleOfFollowRequester.split(':')[1] + if port2Str.isdigit(): + port2=int(port2Str) requestsDir=accountDir+'/requests' followActivityfilename=requestsDir+'/'+handleOfFollowRequester+'.follow' if os.path.isfile(followActivityfilename): diff --git a/skills.py b/skills.py index 195df205b..6a707b5c7 100644 --- a/skills.py +++ b/skills.py @@ -83,7 +83,10 @@ def outboxSkills(baseDir: str,nickname: str,messageJson: {},debug: bool) -> bool return False domain,port=getDomainFromActor(messageJson['actor']) skill=messageJson['object'].replace('"','').split(';')[0].strip() - skillLevelPercent=int(messageJson['object'].replace('"','').split(';')[1].strip()) + skillLevelPercentStr=messageJson['object'].replace('"','').split(';')[1].strip() + skillLevelPercent=50 + if skillLevelPercentStr.isdigit(): + skillLevelPercent=int(skillLevelPercentStr) return setSkillLevel(baseDir,nickname,domain, \ skill,skillLevelPercent) diff --git a/webfinger.py b/webfinger.py index 84930e3bc..02d03c0a4 100644 --- a/webfinger.py +++ b/webfinger.py @@ -48,7 +48,9 @@ def webfingerHandle(session,handle: str,httpPrefix: str,cachedWebfingers: {}, \ return None wfDomain=domain if ':' in wfDomain: - #wfPort=int(wfDomain.split(':')[1]) + #wfPortStr=wfDomain.split(':')[1] + #if wfPortStr.isdigit(): + # wfPort=int(wfPortStr) #if wfPort==80 or wfPort==443: wfDomain=wfDomain.split(':')[0] wf=getWebfingerFromCache(nickname+'@'+wfDomain,cachedWebfingers) diff --git a/webinterface.py b/webinterface.py index 63d6ba068..3f854e3e4 100644 --- a/webinterface.py +++ b/webinterface.py @@ -4923,7 +4923,9 @@ def htmlProfileAfterSearch(recentPostsCache: {},maxRecentPosts: int, \ searchDomain=profileHandle.split('@')[1] searchPort=None if ':' in searchDomain: - searchPort=int(searchDomain.split(':')[1]) + searchPortStr=searchDomain.split(':')[1] + if searchPortStr.isdigit(): + searchPort=int(searchPortStr) searchDomain=searchDomain.split(':')[0] if not searchNickname: if debug: