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

[6.x] Fix mime validation for jpeg files #35518

Merged
merged 2 commits into from Dec 7, 2020
Merged

Conversation

driesvints
Copy link
Member

@driesvints driesvints commented Dec 7, 2020

These changes fixes a regression introduced by recent changes in Symfony and is a follow up to #35419. It makes sure that if either mimes:jpeg or mimes:jpg is used that it doesn't matter wether the file is a .jpg or .jpeg file. This was the previous behaviour.

I've also cleaned up some incorrect casing for the image rule and cleaned up the tests for the mimetypes rule which were a bit out of date it seems.

As a side note it would be much better if these tests were integration tests against actual files but that's out of the scope for this PR.

See #35419 (comment)

$this->assertFalse($v->passes());

$file2 = $this->getMockBuilder(UploadedFile::class)->setMethods(['guessExtension', 'getClientOriginalExtension'])->setConstructorArgs($uploadedFile)->getMock();
$file2->expects($this->any())->method('guessExtension')->willReturn('jpeg');
$file2->expects($this->any())->method('guessExtension')->willReturn('jpg');
Copy link
Member Author

Choose a reason for hiding this comment

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

I've changed this because the recent Symfony change will always return jpg here for jpeg files.

@taylorotwell taylorotwell merged commit 9685c1b into 6.x Dec 7, 2020
@taylorotwell taylorotwell deleted the fix-jpeg-validation branch December 7, 2020 14:26
@it-can
Copy link
Contributor

it-can commented Dec 8, 2020

I think that the same ‘problem’ happens with heic and heif files...

Uploading a .heic file with this validation rule failes

photo' => 'mimes:jpg,bmp,png,heic'

But this works

photo' => 'mimes:jpg,bmp,png,heic,heif'

@driesvints
Copy link
Member Author

I don't know anything about those file types sorry.

@it-can
Copy link
Contributor

it-can commented Dec 8, 2020

I don't know anything about those file types sorry.

yeah its ios default setting for saving photos nowadays... well my workaround works so I'll be fine :-)

@simonj
Copy link

simonj commented Dec 10, 2020

@it-can I had to do this to get it working
mimetypes:image/heic,image/heif,image/heif-sequence,image/heic-sequence

And of course install the imagick on the server plus using something like intervention/image package to get it working.

This was referenced Mar 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants