From 63ced5625028f42331eab729639534c8064ba352 Mon Sep 17 00:00:00 2001 From: Micah Lee Date: Tue, 21 May 2019 10:18:40 -0700 Subject: [PATCH] Update ReceiveMode to no longer rely on slugs --- onionshare/web/receive_mode.py | 30 +++++------------------------- share/static/js/receive.js | 2 +- share/templates/receive.html | 2 +- 3 files changed, 7 insertions(+), 27 deletions(-) diff --git a/onionshare/web/receive_mode.py b/onionshare/web/receive_mode.py index af146cb0..60f421fa 100644 --- a/onionshare/web/receive_mode.py +++ b/onionshare/web/receive_mode.py @@ -34,15 +34,7 @@ class ReceiveModeWeb(object): @self.web.app.route("/") def index(): self.web.add_request(self.web.REQUEST_LOAD, request.path) - - if self.common.settings.get('public_mode'): - upload_action = '/upload' - else: - upload_action = '/{}/upload'.format(self.web.password) - - r = make_response(render_template( - 'receive.html', - upload_action=upload_action)) + r = make_response(render_template('receive.html')) return self.web.add_security_headers(r) @self.web.app.route("/upload", methods=['POST']) @@ -83,11 +75,7 @@ class ReceiveModeWeb(object): return json.dumps({"error_flashes": [msg]}) else: flash(msg, 'error') - - if self.common.settings.get('public_mode'): - return redirect('/') - else: - return redirect('/{}'.format(password_candidate)) + return redirect('/') # Note that flash strings are in English, and not translated, on purpose, # to avoid leaking the locale of the OnionShare user @@ -114,11 +102,7 @@ class ReceiveModeWeb(object): if ajax: return json.dumps({"info_flashes": info_flashes}) else: - if self.common.settings.get('public_mode'): - path = '/' - else: - path = '/{}'.format(password_candidate) - return redirect('{}'.format(path)) + return redirect('/') else: if ajax: return json.dumps({"new_body": render_template('thankyou.html')}) @@ -234,12 +218,8 @@ class ReceiveModeRequest(Request): # Is this a valid upload request? self.upload_request = False if self.method == 'POST': - if self.web.common.settings.get('public_mode'): - if self.path == '/upload' or self.path == '/upload-ajax': - self.upload_request = True - else: - if self.path == '/{}/upload'.format(self.web.password) or self.path == '/{}/upload-ajax'.format(self.web.password): - self.upload_request = True + if self.path == '/upload' or self.path == '/upload-ajax': + self.upload_request = True if self.upload_request: # No errors yet diff --git a/share/static/js/receive.js b/share/static/js/receive.js index c29c726c..cbd60954 100644 --- a/share/static/js/receive.js +++ b/share/static/js/receive.js @@ -121,7 +121,7 @@ $(function(){ $('#uploads').append($upload_div); // Send the request - ajax.open('POST', window.location.pathname.replace(/\/$/, '') + '/upload-ajax', true); + ajax.open('POST', '/upload-ajax', true); ajax.send(formData); }); }); diff --git a/share/templates/receive.html b/share/templates/receive.html index 4f207a03..dd36ac72 100644 --- a/share/templates/receive.html +++ b/share/templates/receive.html @@ -45,7 +45,7 @@ -
+