From dfdf4c032ef5d822c5f3f944d9b1b02ce6c696f1 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Mon, 17 Feb 2020 17:18:21 +0000 Subject: [PATCH] Support use on i2p addresses --- content.py | 8 +++++++- epicyon.py | 7 ++++++- inbox.py | 2 +- utils.py | 8 ++++---- webfinger.py | 4 ++-- webinterface.py | 6 +++--- 6 files changed, 23 insertions(+), 12 deletions(-) diff --git a/content.py b/content.py index 2e66ef4d2..e823bfc1b 100644 --- a/content.py +++ b/content.py @@ -66,6 +66,7 @@ def addWebLinks(content: str) -> str: for w in words: if w.startswith('https://') or \ w.startswith('http://') or \ + w.startswith('i2p://') or \ w.startswith('dat://'): if w.endswith('.') or w.endswith(';'): w=w[:-1] @@ -74,9 +75,11 @@ def addWebLinks(content: str) -> str: markup+='' elif w.startswith('http://'): markup+='' + elif w.startswith('i2p://'): + markup+='' elif w.startswith('dat://'): markup+='' - linkText=w.replace('https://','').replace('http://','').replace('dat://','') + linkText=w.replace('https://','').replace('http://','').replace('dat://','').replace('i2p://','') # prevent links from becoming too long if len(linkText)>maxLinkLength: markup+=''+linkText[:maxLinkLength]+'' @@ -276,6 +279,8 @@ def removeLongWords(content: str,maxWordLength: int,longWordsList: []) -> str: continue elif 'http:' in wordStr: continue + elif 'i2p:' in wordStr: + continue elif 'dat:' in wordStr: continue if '<' in wordStr: @@ -396,6 +401,7 @@ def getMentionsFromHtml(htmlText: str,matchStr=" (str,int): """ port=None if '/profile/' in actor: - domain = actor.split('/profile/')[0].replace('https://','').replace('http://','').replace('dat://','') + domain = actor.split('/profile/')[0].replace('https://','').replace('http://','').replace('i2p://','').replace('dat://','') else: if '/channel/' in actor: - domain = actor.split('/channel/')[0].replace('https://','').replace('http://','').replace('dat://','') + domain = actor.split('/channel/')[0].replace('https://','').replace('http://','').replace('i2p://','').replace('dat://','') else: if '/users/' not in actor: - domain = actor.replace('https://','').replace('http://','').replace('dat://','') + domain = actor.replace('https://','').replace('http://','').replace('i2p://','').replace('dat://','') if '/' in actor: domain=domain.split('/')[0] else: - domain = actor.split('/users/')[0].replace('https://','').replace('http://','').replace('dat://','') + domain = actor.split('/users/')[0].replace('https://','').replace('http://','').replace('i2p://','').replace('dat://','') if ':' in domain: port=int(domain.split(':')[1]) domain=domain.split(':')[0] diff --git a/webfinger.py b/webfinger.py index a3fe33108..84930e3bc 100644 --- a/webfinger.py +++ b/webfinger.py @@ -24,11 +24,11 @@ def parseHandle(handle: str) -> (str,str): return None, None if '/@' in handle: domain, nickname = \ - handle.replace('https://','').replace('http://','').replace('dat://','').split('/@') + handle.replace('https://','').replace('http://','').replace('dat://','').replace('i2p://','').split('/@') else: if '/users/' in handle: domain, nickname = \ - handle.replace('https://','').replace('http://','').replace('dat://','').split('/users/') + handle.replace('https://','').replace('http://','').replace('i2p://','').replace('dat://','').split('/users/') else: if '@' in handle: nickname, domain = handle.split('@') diff --git a/webinterface.py b/webinterface.py index a8230a5f2..a6f83c8e6 100644 --- a/webinterface.py +++ b/webinterface.py @@ -1819,7 +1819,7 @@ def addEmbeddedAudio(translate: {},content: str) -> str: if not w.endswith(extension): continue - if not (w.startswith('http') or w.startswith('dat:') or '/' in w): + if not (w.startswith('http') or w.startswith('dat:') or w.startswith('i2p:') or '/' in w): continue url=w content+='
@unknown' else: - postDomain=postJsonObject['object']['inReplyTo'].replace('https://','').replace('http://','').replace('dat://','') + postDomain=postJsonObject['object']['inReplyTo'].replace('https://','').replace('http://','').replace('dat://','').replace('i2p://','') if '/' in postDomain: postDomain=postDomain.split('/',1)[0] if postDomain: