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

[8.x] Fix validating image/jpeg images after Symfony/Mime update #35416

Closed
wants to merge 5 commits into from
Closed

[8.x] Fix validating image/jpeg images after Symfony/Mime update #35416

wants to merge 5 commits into from

Conversation

Grldk
Copy link
Contributor

@Grldk Grldk commented Nov 30, 2020

Symfony/Mime v5.20 changed the returned extension for an image with image/jpeg mime type: symfony/mime@aa1d922

This breaks laravel image validation, as it relied on a return value of .jpeg. This commit changes .jpeg to .jpg, which fixes the validation. I coudn't find any tests for this part of the framework, but I'm not very familiar with the framework tests, so this might be an oversight on my part.

Edit: Updated the test for this. I'm not sure if getClientOriginalExtension is reached in this case, so I did not alter the extension in that line of the test.

Symfony/Mime v5.20 changed the returned extension for an image with image/jpeg mime type: symfony/mime@aa1d922

This breaks laravel image validation, as it relied on a return value of `.jpeg`. This commit changes `.jpeg` to `.jpg`, which fixes the validation. I coudn't find any tests for this part of the framework, but I'm not very familiar with the framework tests, so this might be an oversight on my part.
@erikgaal
Copy link
Contributor

This will fix #35417.

@@ -1036,7 +1036,7 @@ public function validateLte($attribute, $value, $parameters)
*/
public function validateImage($attribute, $value)
{
return $this->validateMimes($attribute, $value, ['jpeg', 'png', 'gif', 'bmp', 'svg', 'webp']);
return $this->validateMimes($attribute, $value, ['jpg', 'png', 'gif', 'bmp', 'svg', 'webp']);
Copy link
Contributor

@erikgaal erikgaal Nov 30, 2020

Choose a reason for hiding this comment

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

We must keep the original jpeg item in the array for developers who use versions of symfony/mime prior to 5.2.0.

Suggested change
return $this->validateMimes($attribute, $value, ['jpg', 'png', 'gif', 'bmp', 'svg', 'webp']);
return $this->validateMimes($attribute, $value, ['jpeg', 'jpg', 'png', 'gif', 'bmp', 'svg', 'webp']);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, suppose you're right, fixed this

Copy link

@Nyholm Nyholm left a comment

Choose a reason for hiding this comment

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

Thank you.

Im happy with this change.

@GrahamCampbell
Copy link
Member

Please send to 6.x. We will then merge upwards.

@GrahamCampbell
Copy link
Member

Because, yes, Laravel 6 is comparable with symfony mime 5.2.

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

4 participants