From 49f335405e934a43a3c963a575057ba921378010 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Vinot?= Date: Fri, 5 Aug 2022 11:28:44 +0200 Subject: [PATCH] fix: Avoid exceptions on invalid requests --- bin/async_capture.py | 2 ++ website/web/__init__.py | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/bin/async_capture.py b/bin/async_capture.py index a013927..edc290e 100755 --- a/bin/async_capture.py +++ b/bin/async_capture.py @@ -94,6 +94,8 @@ class AsyncCapture(AbstractManager): self.thirdparty_submit(url) else: self.logger.warning(f'Invalid capture {to_capture}.') + await lazy_cleanup.execute() + return self.logger.info(f'Capturing {url} - {uuid}') success, error_message = await self._capture( diff --git a/website/web/__init__.py b/website/web/__init__.py index da23961..2869054 100644 --- a/website/web/__init__.py +++ b/website/web/__init__.py @@ -898,7 +898,9 @@ def capture_web(): elif request.form.get('urls'): # bulk query bulk_captures = [] - for url in request.form['urls'].split('\n'): + for url in request.form['urls'].strip().split('\n'): + if not url: + continue query = capture_query.copy() query['url'] = url new_capture_uuid = lookyloo.enqueue_capture(query, source='web', user=user, authenticated=flask_login.current_user.is_authenticated) @@ -912,6 +914,8 @@ def capture_web(): perma_uuid = lookyloo.enqueue_capture(capture_query, source='web', user=user, authenticated=flask_login.current_user.is_authenticated) time.sleep(2) return redirect(url_for('tree', tree_uuid=perma_uuid)) + else: + flash('Invalid submission: please submit at least a URL or a document.', 'error') elif request.method == 'GET' and request.args.get('url'): url = unquote_plus(request.args['url']).strip() capture_query = {'url': url}