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'):
|
if 'har_file' in parameters and parameters.get('har_file'):
|
||||||
try:
|
try:
|
||||||
har_decoded = base64.b64decode(parameters['har_file'])
|
har_decoded = base64.b64decode(parameters['har_file'])
|
||||||
except Exception as e:
|
try:
|
||||||
return {'error': "Invalid base64-encoding"}, 400
|
# new format
|
||||||
har = json.loads(gzip.decompress(har_decoded))
|
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')
|
last_redirected_url = parameters.get('landing_page')
|
||||||
if 'screenshot_file' in parameters:
|
if 'screenshot_file' in parameters:
|
||||||
screenshot = base64.b64decode(parameters['screenshot_file'])
|
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,
|
lookyloo.store_capture(uuid, is_public=listing, har=har,
|
||||||
last_redirected_url=last_redirected_url,
|
last_redirected_url=last_redirected_url,
|
||||||
png=screenshot, html=html)
|
png=screenshot, html=html)
|
||||||
|
except Exception as e:
|
||||||
|
return {'error': f"Invalid encodings"}, 400
|
||||||
return uuid
|
return uuid
|
||||||
|
|
||||||
elif 'full_capture' in parameters and parameters.get('full_capture'):
|
elif 'full_capture' in parameters and parameters.get('full_capture'):
|
||||||
|
|
Loading…
Reference in New Issue