mirror of https://github.com/CIRCL/lookyloo
Fix: catch errors
parent
c3fc91a868
commit
e2a8121898
|
@ -459,9 +459,14 @@ class UploadCapture(Resource): # type: ignore[misc]
|
|||
if 'har_file' in parameters and parameters.get('har_file'):
|
||||
try:
|
||||
har_decoded = base64.b64decode(parameters['har_file'])
|
||||
except Exception as e:
|
||||
return {'error': "Invalid base64-encoding"}, 400
|
||||
har = json.loads(gzip.decompress(har_decoded))
|
||||
try:
|
||||
# new format
|
||||
har_uncompressed = gzip.decompress(har_decoded)
|
||||
except gzip.BadGzipFile:
|
||||
# old format
|
||||
har_uncompressed = har_decoded
|
||||
|
||||
har = json.loads(har_uncompressed)
|
||||
last_redirected_url = parameters.get('landing_page')
|
||||
if 'screenshot_file' in parameters:
|
||||
screenshot = base64.b64decode(parameters['screenshot_file'])
|
||||
|
@ -470,6 +475,8 @@ class UploadCapture(Resource): # type: ignore[misc]
|
|||
lookyloo.store_capture(uuid, is_public=listing, har=har,
|
||||
last_redirected_url=last_redirected_url,
|
||||
png=screenshot, html=html)
|
||||
except Exception as e:
|
||||
return {'error': f"Invalid encodings"}, 400
|
||||
return uuid
|
||||
|
||||
elif 'full_capture' in parameters and parameters.get('full_capture'):
|
||||
|
|
Loading…
Reference in New Issue