Description
In src/core/views/api_views.py, the MarkerGeneratorAPIView.post() method saves the processed image as PNG but declares the MIME type as image/jpeg in the base64 data URI. This mismatch can cause display issues in browsers that strictly validate the MIME type.
Location
File: src/core/views/api_views.py
Class: MarkerGeneratorAPIView
Method: post()
Branch: develop
Current Code
# Image is saved as PNG:
transformed_image.save(in_mem_file, format="PNG")
# But the MIME type is declared as JPEG:
transformed_image = f"data:image/jpeg;base64,{base64_encoded_result_str}"
Problem
The image is encoded as PNG (format="PNG") but the data URI prefix declares it as image/jpeg. This is a MIME type mismatch. Some browsers may refuse to render the image correctly, and any downstream code that checks the MIME type will receive incorrect information.
Suggested Fix
Change the MIME type in the data URI to match the actual image format:
transformed_image = f"data:image/png;base64,{base64_encoded_result_str}"
Alternatively, if JPEG is the desired format, change the save format:
transformed_image.save(in_mem_file, format="JPEG")
transformed_image = f"data:image/jpeg;base64,{base64_encoded_result_str}"
Severity
Medium — May cause the generated marker preview to not display correctly in strict browsers.
Description
In
src/core/views/api_views.py, theMarkerGeneratorAPIView.post()method saves the processed image as PNG but declares the MIME type asimage/jpegin the base64 data URI. This mismatch can cause display issues in browsers that strictly validate the MIME type.Location
File:
src/core/views/api_views.pyClass:
MarkerGeneratorAPIViewMethod:
post()Branch:
developCurrent Code
Problem
The image is encoded as PNG (
format="PNG") but the data URI prefix declares it asimage/jpeg. This is a MIME type mismatch. Some browsers may refuse to render the image correctly, and any downstream code that checks the MIME type will receive incorrect information.Suggested Fix
Change the MIME type in the data URI to match the actual image format:
Alternatively, if JPEG is the desired format, change the save format:
Severity
Medium — May cause the generated marker preview to not display correctly in strict browsers.