From 9857d9fce812f84c9a42d8cb84aed39348e05745 Mon Sep 17 00:00:00 2001 From: Micah Lee Date: Sun, 20 May 2018 11:16:09 -0700 Subject: [PATCH] Make the receive.html template not use slugs if receive_public_mode is True, and fix some bugs with receive routes --- onionshare/web.py | 24 +++++++++++++++++++----- share/templates/receive.html | 4 ++-- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/onionshare/web.py b/onionshare/web.py index d3e9f3c7..bf65ade6 100644 --- a/onionshare/web.py +++ b/onionshare/web.py @@ -288,9 +288,17 @@ class Web(object): def index_logic(): self.add_request(Web.REQUEST_LOAD, request.path) + if self.common.settings.get('receive_public_mode'): + upload_action = '/upload' + close_action = '/close' + else: + upload_action = '/{}/upload'.format(self.slug) + close_action = '/{}/close'.format(self.slug) + r = make_response(render_template( 'receive.html', - slug=self.slug, + upload_action=upload_action, + close_action=close_action, receive_allow_receiver_shutdown=self.common.settings.get('receive_allow_receiver_shutdown'))) return self.add_security_headers(r) @@ -324,7 +332,10 @@ class Web(object): valid = False if not valid: flash('Error uploading, please inform the OnionShare user') - return redirect('/{}'.format(slug_candidate)) + if self.common.settings.get('receive_public_mode'): + return redirect('/') + else: + return redirect('/{}'.format(slug_candidate)) files = request.files.getlist('file[]') filenames = [] @@ -383,14 +394,17 @@ class Web(object): for filename in filenames: flash('Uploaded {}'.format(filename)) - return redirect('/{}'.format(slug_candidate)) + if self.common.settings.get('receive_public_mode'): + return redirect('/') + else: + return redirect('/{}'.format(slug_candidate)) @self.app.route("//upload", methods=['POST']) def upload(slug_candidate): self.check_slug_candidate(slug_candidate) return upload_logic(slug_candidate) - @self.app.route("/upload") + @self.app.route("/upload", methods=['POST']) def upload_public(): if not self.common.settings.get('receive_public_mode'): return self.error404() @@ -411,7 +425,7 @@ class Web(object): self.check_slug_candidate(slug_candidate) return close_logic(slug_candidate) - @self.app.route("/upload") + @self.app.route("/close", methods=['POST']) def close_public(): if not self.common.settings.get('receive_public_mode'): return self.error404() diff --git a/share/templates/receive.html b/share/templates/receive.html index 7cc4319f..81b43616 100644 --- a/share/templates/receive.html +++ b/share/templates/receive.html @@ -17,7 +17,7 @@

Send Files

Select the files you want to send, then click "Send Files"...

-
+

@@ -35,7 +35,7 @@
{% if receive_allow_receiver_shutdown %} - +
{% endif %}