From 42f93d00e2e1de9ede0a0987ad35cb9d154fb363 Mon Sep 17 00:00:00 2001 From: Giovanni Pellerano Date: Sun, 29 Sep 2019 13:19:05 +0200 Subject: [PATCH] Add support for Onion Services V3 (#353) --- tor2web/t2w.py | 10 +++++----- tor2web/utils/misc.py | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tor2web/t2w.py b/tor2web/t2w.py index 97a342f3..26421568 100644 --- a/tor2web/t2w.py +++ b/tor2web/t2w.py @@ -818,7 +818,7 @@ def process(self): else: self.var['basehost'] = config.basehost - rexp['w2t'] = re.compile(b'(http:|https:)?//([a-z0-9\.]*[a-z0-9]{16})\.' + self.var['basehost'].encode('utf-8'), re.I) + rexp['w2t'] = re.compile(b'(http:|https:)?//([a-z0-9\.]*[a-z0-9]{56})\.' + self.var['basehost'].encode('utf-8'), re.I) # the requested resource is remote, we act as proxy if config.mode == 'TRANSLATION' and request.host in hosts_map: @@ -1349,10 +1349,10 @@ def umask(mask): rexp = { 'body': re.compile(b'()', re.I), - 'w2t': re.compile(b'(http:|https:)?\/\/([a-z0-9\.]*[a-z0-9]{16})' + config.basehost.encode('utf-8'), re.I), - 't2w': re.compile(b'(http:|https:)?\/\/([a-z0-9\.]*[a-z0-9]{16})\.onion', re.I), - 'set_cookie_t2w': re.compile(b'domain=([a-z0-9\.]*[a-z0-9]{16})\.onion', re.I), - 'html_t2w': re.compile( b'(archive|background|cite|classid|codebase|data|formaction|href|icon|longdesc|manifest|poster|profile|src|url|usemap|)([\s]*=[\s]*[\'\"]?)(?:http:|https:)?\/\/([a-z0-9\.]*[a-z0-9]{16})\.onion([\ \'\"\/])', re.I) + 'w2t': re.compile(b'(http:|https:)?\/\/([a-z0-9\.]*[a-z0-9]{16,56})' + config.basehost.encode('utf-8'), re.I), + 't2w': re.compile(b'(http:|https:)?\/\/([a-z0-9\.]*[a-z0-9]{16,56})\.onion', re.I), + 'set_cookie_t2w': re.compile(b'domain=([a-z0-9\.]*[a-z0-9]{16,56})\.onion', re.I), + 'html_t2w': re.compile( b'(archive|background|cite|classid|codebase|data|formaction|href|icon|longdesc|manifest|poster|profile|src|url|usemap|)([\s]*=[\s]*[\'\"]?)(?:http:|https:)?\/\/([a-z0-9\.]*[a-z0-9]{16,56})\.onion([\ \'\"\/])', re.I) } # ############################################################################## diff --git a/tor2web/utils/misc.py b/tor2web/utils/misc.py index e8b0ca5c..afbea5c6 100644 --- a/tor2web/utils/misc.py +++ b/tor2web/utils/misc.py @@ -60,5 +60,5 @@ def is_onion(hostname): Check to see if the address is a .onion. returns the onion address as a string if True else returns False """ - pattern = re.compile('^([0-9a-z]){16}.onion$') + pattern = re.compile('^([a-z0-9]){16,56}.onion$') return pattern.match(hostname) != None