fix: Avoid exceptions on invalid requests

pull/483/head
Raphaël Vinot 2022-08-05 11:28:44 +02:00
parent 4280a4e11f
commit 49f335405e
2 changed files with 7 additions and 1 deletions

View File

@ -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(

View File

@ -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}