fix: close library upload flow and harden image storage
This commit is contained in:
@@ -61,7 +61,7 @@ class PhotosCache:
|
||||
os.fsync(handle.fileno())
|
||||
if not 0 < part.stat().st_size <= self.max_bytes:
|
||||
raise ValueError()
|
||||
with Image.open(part) as image:
|
||||
with Image.open(part, formats=("JPEG", "PNG", "WEBP")) as image:
|
||||
if image.format not in ("JPEG", "PNG", "WEBP"):
|
||||
raise ValueError()
|
||||
if image.width * image.height > MAX_IMAGE_PIXELS:
|
||||
@@ -69,7 +69,7 @@ class PhotosCache:
|
||||
image.verify()
|
||||
# Decode before committing; truncated/compressed-bomb payloads
|
||||
# must never become a reusable cache hit.
|
||||
with Image.open(part) as image:
|
||||
with Image.open(part, formats=("JPEG", "PNG", "WEBP")) as image:
|
||||
image.load()
|
||||
part.replace(path)
|
||||
self.downloads += 1
|
||||
|
||||
Reference in New Issue
Block a user