mirror of
https://github.com/onionshare/onionshare.git
synced 2025-06-07 06:13:03 -04:00
Check for public_mode in the check_slug_candidate function, to make 404 errors work again during public mode
This commit is contained in:
parent
8bb75cc530
commit
9815c612eb
1 changed files with 12 additions and 13 deletions
|
@ -143,8 +143,7 @@ class Web(object):
|
||||||
"""
|
"""
|
||||||
@self.app.route("/<slug_candidate>")
|
@self.app.route("/<slug_candidate>")
|
||||||
def index(slug_candidate):
|
def index(slug_candidate):
|
||||||
if not self.common.settings.get('public_mode'):
|
self.check_slug_candidate(slug_candidate)
|
||||||
self.check_slug_candidate(slug_candidate)
|
|
||||||
return index_logic()
|
return index_logic()
|
||||||
|
|
||||||
@self.app.route("/")
|
@self.app.route("/")
|
||||||
|
@ -187,8 +186,7 @@ class Web(object):
|
||||||
|
|
||||||
@self.app.route("/<slug_candidate>/download")
|
@self.app.route("/<slug_candidate>/download")
|
||||||
def download(slug_candidate):
|
def download(slug_candidate):
|
||||||
if not self.common.settings.get('public_mode'):
|
self.check_slug_candidate(slug_candidate)
|
||||||
self.check_slug_candidate(slug_candidate)
|
|
||||||
return download_logic()
|
return download_logic()
|
||||||
|
|
||||||
@self.app.route("/download")
|
@self.app.route("/download")
|
||||||
|
@ -331,8 +329,7 @@ class Web(object):
|
||||||
|
|
||||||
@self.app.route("/<slug_candidate>")
|
@self.app.route("/<slug_candidate>")
|
||||||
def index(slug_candidate):
|
def index(slug_candidate):
|
||||||
if not self.common.settings.get('public_mode'):
|
self.check_slug_candidate(slug_candidate)
|
||||||
self.check_slug_candidate(slug_candidate)
|
|
||||||
return index_logic()
|
return index_logic()
|
||||||
|
|
||||||
@self.app.route("/")
|
@self.app.route("/")
|
||||||
|
@ -430,8 +427,7 @@ class Web(object):
|
||||||
|
|
||||||
@self.app.route("/<slug_candidate>/upload", methods=['POST'])
|
@self.app.route("/<slug_candidate>/upload", methods=['POST'])
|
||||||
def upload(slug_candidate):
|
def upload(slug_candidate):
|
||||||
if not self.common.settings.get('public_mode'):
|
self.check_slug_candidate(slug_candidate)
|
||||||
self.check_slug_candidate(slug_candidate)
|
|
||||||
return upload_logic(slug_candidate)
|
return upload_logic(slug_candidate)
|
||||||
|
|
||||||
@self.app.route("/upload", methods=['POST'])
|
@self.app.route("/upload", methods=['POST'])
|
||||||
|
@ -452,8 +448,7 @@ class Web(object):
|
||||||
|
|
||||||
@self.app.route("/<slug_candidate>/close", methods=['POST'])
|
@self.app.route("/<slug_candidate>/close", methods=['POST'])
|
||||||
def close(slug_candidate):
|
def close(slug_candidate):
|
||||||
if not self.common.settings.get('public_mode'):
|
self.check_slug_candidate(slug_candidate)
|
||||||
self.check_slug_candidate(slug_candidate)
|
|
||||||
return close_logic(slug_candidate)
|
return close_logic(slug_candidate)
|
||||||
|
|
||||||
@self.app.route("/close", methods=['POST'])
|
@self.app.route("/close", methods=['POST'])
|
||||||
|
@ -574,10 +569,14 @@ class Web(object):
|
||||||
self.app.logger.addHandler(log_handler)
|
self.app.logger.addHandler(log_handler)
|
||||||
|
|
||||||
def check_slug_candidate(self, slug_candidate, slug_compare=None):
|
def check_slug_candidate(self, slug_candidate, slug_compare=None):
|
||||||
if not slug_compare:
|
self.common.log('Web', 'check_slug_candidate: slug_candidate={}, slug_compare={}'.format(slug_candidate, slug_compare))
|
||||||
slug_compare = self.slug
|
if self.common.settings.get('public_mode'):
|
||||||
if not hmac.compare_digest(slug_compare, slug_candidate):
|
|
||||||
abort(404)
|
abort(404)
|
||||||
|
else:
|
||||||
|
if not slug_compare:
|
||||||
|
slug_compare = self.slug
|
||||||
|
if not hmac.compare_digest(slug_compare, slug_candidate):
|
||||||
|
abort(404)
|
||||||
|
|
||||||
def force_shutdown(self):
|
def force_shutdown(self):
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue