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

Fix invalid format MIME type definition #835

Merged
merged 5 commits into from
Nov 16, 2022

Conversation

xdanik
Copy link
Contributor

@xdanik xdanik commented Nov 15, 2022

I have discovered that $image->show() was setting invalid Content-Type header. "jpg" in case of "jpg" format instead of "image/jpg".

There seems to be an invalid argument order in the constructor call to Imagine\Image\Format.
The constructor signature is:
private function __construct($id, $mimeType, $canonicalFileExtension, $alternativeIDs = array())

While callers were clearly setting MIME type into 3. argument instead of second one.

src/Image/Format.php Outdated Show resolved Hide resolved
Co-authored-by: Martin Auswöger <martin@auswoeger.com>
@xdanik xdanik requested a review from ausi November 15, 2022 10:34
Copy link
Collaborator

@ausi ausi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding a tests/tests/Image/FormatTest.php would make sense too I think ☺️

@xdanik
Copy link
Contributor Author

xdanik commented Nov 15, 2022

I have added simple unit test that asserts expected MIME types for a few basic image formats.

@mlocati mlocati merged commit 9965558 into php-imagine:develop Nov 16, 2022
@xdanik xdanik deleted the format-mime-type-fix branch November 16, 2022 13:07
@vlakoff
Copy link
Contributor

vlakoff commented Nov 16, 2022

Nice catch! I noticed you also fixed the file extension for WBMP.

@vlakoff vlakoff mentioned this pull request Nov 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants