diff options
author | Miguel Jacq <mig@mig5.net> | 2019-09-09 16:35:05 +1000 |
---|---|---|
committer | Miguel Jacq <mig@mig5.net> | 2019-09-09 16:35:05 +1000 |
commit | 90ebc3aab424637dbb75017df6b0204b82d6fe69 (patch) | |
tree | 0cbb32ff8726d47fa6ab432fa574d48070b6f5a1 /onionshare | |
parent | 8e238ab2d66c336029a54f54f6d989b46964d448 (diff) | |
download | onionshare-90ebc3aab424637dbb75017df6b0204b82d6fe69.tar.gz onionshare-90ebc3aab424637dbb75017df6b0204b82d6fe69.zip |
Fix the discrepancy between SendBaseModeWeb and Web objects' separate cur_history_id attibutes, ensuring that when we call web.error404() we send a new history_id integer for communicating back to the frontend. Add tests for this
Diffstat (limited to 'onionshare')
-rw-r--r-- | onionshare/web/send_base_mode.py | 5 | ||||
-rw-r--r-- | onionshare/web/share_mode.py | 12 | ||||
-rw-r--r-- | onionshare/web/web.py | 7 |
3 files changed, 14 insertions, 10 deletions
diff --git a/onionshare/web/send_base_mode.py b/onionshare/web/send_base_mode.py index a6ad2307..67fb26d0 100644 --- a/onionshare/web/send_base_mode.py +++ b/onionshare/web/send_base_mode.py @@ -29,6 +29,9 @@ class SendBaseModeWeb: # one download at a time. self.download_in_progress = False + # This tracks the history id + self.cur_history_id = 0 + self.define_routes() self.init() @@ -264,4 +267,4 @@ class SendBaseModeWeb: """ Inherited class will implement this. """ - pass
\ No newline at end of file + pass diff --git a/onionshare/web/share_mode.py b/onionshare/web/share_mode.py index c9d9b229..f52bc2c7 100644 --- a/onionshare/web/share_mode.py +++ b/onionshare/web/share_mode.py @@ -207,11 +207,15 @@ class ShareModeWeb(SendBaseModeWeb): if self.download_individual_files: return self.stream_individual_file(filesystem_path) else: - return self.web.error404() + history_id = self.cur_history_id + self.cur_history_id += 1 + return self.web.error404(history_id) # 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 / @@ -223,7 +227,9 @@ class ShareModeWeb(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) def build_zipfile_list(self, filenames, processed_size_callback=None): self.common.log("ShareModeWeb", "build_zipfile_list") diff --git a/onionshare/web/web.py b/onionshare/web/web.py index 6cd30c93..2b0d2812 100644 --- a/onionshare/web/web.py +++ b/onionshare/web/web.py @@ -63,9 +63,6 @@ class Web: self.auth = HTTPBasicAuth() self.auth.error_handler(self.error401) - # This tracks the history id - self.cur_history_id = 0 - # Verbose mode? if self.common.verbose: self.verbose_mode() @@ -204,9 +201,7 @@ class Web: r = make_response(render_template('403.html', static_url_path=self.static_url_path), 403) return self.add_security_headers(r) - def error404(self): - history_id = self.cur_history_id - self.cur_history_id += 1 + def error404(self, history_id): self.add_request(self.REQUEST_INDIVIDUAL_FILE_STARTED, '{}'.format(request.path), { 'id': history_id, 'status_code': 404 |