Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FW][FIX] base: avoid fail with wrong mimetype #162989

Conversation

fw-bot
Copy link
Contributor

@fw-bot fw-bot commented Apr 23, 2024

Uploading a WEBP or SVG file disguised with a proper file extension (JPG, PNG) will cause a traceback because img.image is not populated when there is an empty source, SVG, or WEBP file uploaded as this code should not be reached with these file types.

The reason this occurs is because we check for the file extension when deciding to post process an image, but when we get to initializing the ImageProcess object, we then check the actual file structure to verify the type of file.

This is a workaround for the time being, but should not be a final solution in future versions.

Adding a null check on img.image in the _postprocess_contents method in order to avoid attempting to access the size of this image when it is null.

Raises a user error in order to trigger the catch and exit the code while logging the error and 'Post processing ignored:'.

opw-3672250

I confirm I have signed the CLA and read the PR guidelines at www.odoo.com/submit-pr

Forward-Port-Of: #156209

Uploading a WEBP or SVG file disguised with a proper file extension (JPG, PNG)
will cause a traceback because img.image is
not populated when there is an empty source, SVG, or WEBP file uploaded
as this code should not be reached with these file types.

The reason this occurs is because we check for the file extension when
deciding to post process an image, but when we get to initializing the
ImageProcess object, we then check the actual file structure to verify
the type of file.

This is a workaround for the time being, but should not be a final
solution in future versions.

Adding a null check on img.image in the _postprocess_contents method
in order to avoid attempting to access the size of this image when it is
null.

Raises a user error in order to trigger the catch and exit the code
while logging the error and 'Post processing ignored:'.

Includes test for this new workflow with no errors.

opw-3672250

X-original-commit: e9750b1
@robodoo
Copy link
Contributor

robodoo commented Apr 23, 2024

Pull request status dashboard.

@fw-bot
Copy link
Contributor Author

fw-bot commented Apr 23, 2024

This PR targets saas-17.1 and is part of the forward-port chain. Further PRs will be created up to master.

More info at https://github.com/odoo/odoo/wiki/Mergebot#forward-port

@robodoo robodoo added the forwardport This PR was created by @fw-bot label Apr 23, 2024
@C3POdoo C3POdoo added the OE the report is linked to a support ticket (opw-...) label Apr 23, 2024
robodoo pushed a commit that referenced this pull request Apr 24, 2024
Uploading a WEBP or SVG file disguised with a proper file extension (JPG, PNG)
will cause a traceback because img.image is
not populated when there is an empty source, SVG, or WEBP file uploaded
as this code should not be reached with these file types.

The reason this occurs is because we check for the file extension when
deciding to post process an image, but when we get to initializing the
ImageProcess object, we then check the actual file structure to verify
the type of file.

This is a workaround for the time being, but should not be a final
solution in future versions.

Adding a null check on img.image in the _postprocess_contents method
in order to avoid attempting to access the size of this image when it is
null.

Raises a user error in order to trigger the catch and exit the code
while logging the error and 'Post processing ignored:'.

Includes test for this new workflow with no errors.

opw-3672250

closes #162989

X-original-commit: e9750b1
Signed-off-by: Benoit Socias (bso) <bso@odoo.com>
Signed-off-by: Ryan Cen (ryce) <ryce@odoo.com>
@robodoo robodoo closed this Apr 24, 2024
@fw-bot fw-bot deleted the saas-17.1-saas-16.4-opw-3672250-ryce-vlqM-fw branch May 8, 2024 01:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
forwardport This PR was created by @fw-bot OE the report is linked to a support ticket (opw-...)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants