if no referer is given, assume the worst

only way to avoid redirect loops if referers are not set (e.g. python requests)
This commit is contained in:
Min RK
2019-02-27 15:21:22 +01:00
parent 8d01b0356b
commit 89c85aca37

View File

@@ -1389,7 +1389,7 @@ class UserUrlHandler(BaseHandler):
query_parts['redirects'] = redirects + 1
url_parts = url_parts._replace(query=urlencode(query_parts, doseq=True))
target = urlunparse(url_parts)
elif '/user/' in referer:
elif '/user/{}'.format(user.name) in referer or not referer:
# add first counter only if it's a redirect from /user/:name -> /hub/user/:name
target = url_concat(target, {'redirects': 1})