From 86a2b35d9ddc6c0fb9d068ca0f45c48fbfcaa219 Mon Sep 17 00:00:00 2001 From: Miguel Jacq Date: Mon, 9 Sep 2019 17:22:18 +1000 Subject: [PATCH] Ensure we increment and return the history_id when throwing error404() in website mode. Add a route for /favicon.ico unless we are in website mode (website might have its own favicon) --- onionshare/web/web.py | 7 ++++++- onionshare/web/website_mode.py | 8 ++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/onionshare/web/web.py b/onionshare/web/web.py index 2b0d2812..ca63e520 100644 --- a/onionshare/web/web.py +++ b/onionshare/web/web.py @@ -10,7 +10,7 @@ from distutils.version import LooseVersion as Version from urllib.request import urlopen import flask -from flask import Flask, request, render_template, abort, make_response, __version__ as flask_version +from flask import Flask, request, render_template, abort, make_response, send_file, __version__ as flask_version from flask_httpauth import HTTPBasicAuth from .. import strings @@ -178,6 +178,11 @@ class Web: return "" abort(404) + if self.mode != 'website': + @self.app.route("/favicon.ico") + def favicon(): + return send_file('{}/img/favicon.ico'.format(self.common.get_resource_path('static'))) + def error401(self): auth = request.authorization if auth: diff --git a/onionshare/web/website_mode.py b/onionshare/web/website_mode.py index 55e5c1d4..0b7602ea 100644 --- a/onionshare/web/website_mode.py +++ b/onionshare/web/website_mode.py @@ -70,7 +70,9 @@ class WebsiteModeWeb(SendBaseModeWeb): # If it's not a directory or file, throw a 404 else: - return self.web.error404() + history_id = self.cur_history_id + self.cur_history_id += 1 + return self.web.error404(history_id) else: # Special case loading / @@ -87,4 +89,6 @@ class WebsiteModeWeb(SendBaseModeWeb): else: # If the path isn't found, throw a 404 - return self.web.error404() + history_id = self.cur_history_id + self.cur_history_id += 1 + return self.web.error404(history_id)