-
Notifications
You must be signed in to change notification settings - Fork 11.1k
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
Conversation
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.
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']); |
There was a problem hiding this comment.
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
.
return $this->validateMimes($attribute, $value, ['jpg', 'png', 'gif', 'bmp', 'svg', 'webp']); | |
return $this->validateMimes($attribute, $value, ['jpeg', 'jpg', 'png', 'gif', 'bmp', 'svg', 'webp']); |
There was a problem hiding this comment.
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
There was a problem hiding this 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.
Please send to 6.x. We will then merge upwards. |
Because, yes, Laravel 6 is comparable with symfony mime 5.2. |
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.