Merge branch 'master' of aewens/0x0 into master

This commit is contained in:
Ben Harris 2018-10-04 12:34:53 -04:00 committed by Gitea
commit 3e4eb055c7
1 changed files with 12 additions and 6 deletions

View File

@ -132,6 +132,12 @@ def is_fhost_url(url):
return url.startswith(fhost_url()) or url.startswith(fhost_url("https"))
def shorten(url):
# handler to convert gopher links to HTTP(S) proxy
gopher = "gopher://"
length = len(gopher)
if url[:length] == gopher:
url = "https://gopher.tilde.team/{}".format(url[length:])
if len(url) > app.config["MAX_URL_LENGTH"]:
abort(414)
@ -233,14 +239,14 @@ def store_file(f, addr):
return sf.geturl()
def store_url(url, addr):
if is_fhost_url(url):
return segfault(508)
# handler to convert gopher links to HTTP(S) proxy
gopher = "gopher://"
if url[:len(gopher)] = gopher:
address = url.split(gopher, 1)[1]
url = "https://gopher.tilde.team/{}".format(address)
length = len(gopher)
if url[:length] == gopher:
url = "https://gopher.tilde.team/{}".format(url[length:])
if is_fhost_url(url):
return segfault(508)
h = { "Accept-Encoding" : "identity" }
r = requests.get(url, stream=True, verify=False, headers=h)