Fix: close the uploaded logo image with a context manager when sanitizing (#14888)

This commit is contained in:
Trenton H authored and GitHub committed 2026-11-26 18:31:35 -08:00
1 parent 0a8de70c26
commit 33fb750529
1 file changed
+1 -4
+1 -4
View File
@@ -296,9 +296,8 @@ class ApplicationConfigurationSerializer(
return super().update(instance, validated_data)
def _sanitize_raster_image(self, file: UploadedFile) -> UploadedFile:
try:
with Image.open(file) as image:
data = BytesIO()
image = Image.open(file)
image.save(data, format=image.format)
data.seek(0)
@@ -310,8 +309,6 @@ class ApplicationConfigurationSerializer(
size=data.getbuffer().nbytes,
charset=getattr(file, "charset", None),
)
finally:
image.close()
def validate_app_logo(self, file: UploadedFile):
"""