From 97b5984afff1b00743380e775b961eac5ff3b3a7 Mon Sep 17 00:00:00 2001 From: Micah Lee Date: Tue, 21 May 2019 10:08:54 -0700 Subject: [PATCH] Fix building the URL in CLI mode, and removing the slug from the download button in share mode --- onionshare/__init__.py | 19 +++++++++++++------ onionshare/web/share_mode.py | 25 +++++++------------------ share/templates/send.html | 4 ---- 3 files changed, 20 insertions(+), 28 deletions(-) diff --git a/onionshare/__init__.py b/onionshare/__init__.py index e2ff50a2..f0889263 100644 --- a/onionshare/__init__.py +++ b/onionshare/__init__.py @@ -27,6 +27,15 @@ from .web import Web from .onion import * from .onionshare import OnionShare + +def build_url(common, app, web): + # Build the URL + if common.settings.get('public_mode'): + return 'http://{0:s}'.format(app.onion_host) + else: + return 'http://onionshare:{0:s}@{1:s}'.format(web.password, app.onion_host) + + def main(cwd=None): """ The main() function implements all of the logic that the command-line version of @@ -128,12 +137,6 @@ def main(cwd=None): app.set_stealth(stealth) app.choose_port() - # Build the URL - if common.settings.get('public_mode'): - url = 'http://{0:s}'.format(app.onion_host) - else: - url = 'http://onionshare:{0:s}@{1:s}'.format(web.password, app.onion_host) - # Delay the startup if a startup timer was set if autostart_timer > 0: # Can't set a schedule that is later than the auto-stop timer @@ -142,6 +145,7 @@ def main(cwd=None): sys.exit() app.start_onion_service(False, True) + url = build_url(common, app, web) schedule = datetime.now() + timedelta(seconds=autostart_timer) if mode == 'receive': print("Files sent to you appear in this folder: {}".format(common.settings.get('data_dir'))) @@ -218,6 +222,9 @@ def main(cwd=None): common.settings.set('password', web.password) common.settings.save() + # Build the URL + url = build_url(common, app, web) + print('') if autostart_timer > 0: print("Server started") diff --git a/onionshare/web/share_mode.py b/onionshare/web/share_mode.py index bede4a36..22c58559 100644 --- a/onionshare/web/share_mode.py +++ b/onionshare/web/share_mode.py @@ -64,24 +64,13 @@ class ShareModeWeb(object): else: self.filesize = self.download_filesize - if self.web.password: - r = make_response(render_template( - 'send.html', - password=self.web.password, - file_info=self.file_info, - filename=os.path.basename(self.download_filename), - filesize=self.filesize, - filesize_human=self.common.human_readable_filesize(self.download_filesize), - is_zipped=self.is_zipped)) - else: - # If download is allowed to continue, serve download page - r = make_response(render_template( - 'send.html', - file_info=self.file_info, - filename=os.path.basename(self.download_filename), - filesize=self.filesize, - filesize_human=self.common.human_readable_filesize(self.download_filesize), - is_zipped=self.is_zipped)) + r = make_response(render_template( + 'send.html', + file_info=self.file_info, + filename=os.path.basename(self.download_filename), + filesize=self.filesize, + filesize_human=self.common.human_readable_filesize(self.download_filesize), + is_zipped=self.is_zipped)) return self.web.add_security_headers(r) @self.web.app.route("/download") diff --git a/share/templates/send.html b/share/templates/send.html index 2a56829a..7be9e100 100644 --- a/share/templates/send.html +++ b/share/templates/send.html @@ -15,11 +15,7 @@