From e59796b42693458fd3efaf2b8d5426487933e34e Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Sat, 11 Jul 2020 17:57:00 +0100 Subject: [PATCH] Use calling domain when generating delete screen --- daemon.py | 2 +- webinterface.py | 18 ++++++++++++++++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/daemon.py b/daemon.py index 670ee4f1c..7cf42ff95 100644 --- a/daemon.py +++ b/daemon.py @@ -3164,7 +3164,7 @@ class PubServer(BaseHTTPRequestHandler): self.server.session, self.server.baseDir, deleteUrl, self.server.httpPrefix, __version__, self.server.cachedWebfingers, - self.server.personCache) + self.server.personCache, callingDomain) if deleteStr: self._set_headers('text/html', len(deleteStr), cookie, callingDomain) diff --git a/webinterface.py b/webinterface.py index d7e86d6cd..b57c388c8 100644 --- a/webinterface.py +++ b/webinterface.py @@ -5112,7 +5112,8 @@ def htmlDeletePost(recentPostsCache: {}, maxRecentPosts: int, translate, pageNumber: int, session, baseDir: str, messageId: str, httpPrefix: str, projectVersion: str, - wfRequest: {}, personCache: {}) -> str: + wfRequest: {}, personCache: {}, + callingDomain: str) -> str: """Shows a screen asking to confirm the deletion of a post """ if '/statuses/' not in messageId: @@ -5121,6 +5122,10 @@ def htmlDeletePost(recentPostsCache: {}, maxRecentPosts: int, actor = messageId.split('/statuses/')[0] nickname = getNicknameFromActor(actor) domain, port = getDomainFromActor(actor) + domainFull = domain + if port: + if port != 80 and port != 443: + domainFull = domain + ':' + str(port) postFilename = locatePost(baseDir, nickname, domain, messageId) if not postFilename: @@ -5157,7 +5162,16 @@ def htmlDeletePost(recentPostsCache: {}, maxRecentPosts: int, deletePostStr += \ '

' + \ translate['Delete this post?'] + '

' - deletePostStr += '
' + postActor = actor + if callingDomain not in actor and domainFull in actor: + if callingDomain.endswith('.onion') or \ + callingDomain.endswith('.i2p'): + postActor = \ + 'http://' + callingDomain + actor.split(domainFull)[1] + print('Changed POST domain from ' + actor + ' to ' + postActor) + + deletePostStr += \ + ' ' deletePostStr += \ ' '