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

symfony/mime v5.2.0 broken file upload #39225

Closed
naelsaid opened this issue Nov 30, 2020 · 10 comments
Closed

symfony/mime v5.2.0 broken file upload #39225

naelsaid opened this issue Nov 30, 2020 · 10 comments

Comments

@naelsaid
Copy link

Symfony version(s) affected: symfony/mime v5.2.0

Description
Today I ran composer update for a project and found that file uploads in all forms broke. After investigating the problem I figured out that if I go back to symfony/mime v5.1.9 everything works again.

Our project uses Laravel 8 which in turn uses symfony/mime

@Nyholm
Copy link
Member

Nyholm commented Nov 30, 2020

Thank you.
Could you show some a minimal example of what is broken?

@naelsaid
Copy link
Author

naelsaid commented Nov 30, 2020

Unfortunately I am not an expert in debugging such kind of errors. All I can provide is that in Laravel I get the error

Illuminate\Validation\ValidationException: The given data was invalid

When I upload an image.
this is the validation rules set for the uploaded image

'mimes' => 'png,jpg,gif,jpeg',

Hope it helps.

i thought it might be a Laravel issue but when I downgrade symfony/mime to v5.1.9 everything works like normal. So I do not think it is a Laravel issue.

@Nyholm
Copy link
Member

Nyholm commented Nov 30, 2020

Hm.. We are very much in the "Something is wrong" area. =)

I need something more.

It sounds like you have an image upload form and validation that it only accepts some specific extensions. But you get a validation error.

I see on your validation rules you have mimes key and the value is a list of extensions. That does not look correct.

Is there an extensions key you can use instead? Or will it be better if you used mimes instead? Example mime is: image/png

@fragkp
Copy link

fragkp commented Nov 30, 2020

I tracked the issue further to this file:
https://github.com/symfony/symfony/blob/5.x/src/Symfony/Component/HttpFoundation/File/File.php#L61

getExtensions() from the MimeTypes class returns a different order for image/jpeg mime.

5.1:

array:3 [
  0 => "jpeg"
  1 => "jpg"
  2 => "jpe"
]

5.2:

array:3 [
  0 => "jpg"
  1 => "jpeg"
  2 => "jpe"
]

@Nyholm
Copy link
Member

Nyholm commented Nov 30, 2020

Thank you @fragkp. You are correct. But that is fine, ie, there is no BC break and @mnaas code should not fail because of it.

@naelsaid
Copy link
Author

naelsaid commented Nov 30, 2020

Yes I was investigating and found the same problem
I opened an issue where I do not know if this is a Laravel or Symfony/mime issue
laravel/framework#35417

@Nyholm
Copy link
Member

Nyholm commented Nov 30, 2020

Thank you for the reports.

@fragkp found the cause of this change and @NEGits fixed it in laravel/framework#35416

Awesome work!

@Nyholm Nyholm closed this as completed Nov 30, 2020
@driesvints
Copy link
Contributor

Not that I want to start a discussion around this @Nyholm but imo this is a change in behavior which should be considered a BC break. It's a gray area for sure. Anyway, I think we can work around this easily. Thanks for your work 👍

@mfn
Copy link

mfn commented Nov 30, 2020

FTR, the actually merged PR for 6.x was laravel/framework#35419

@Nyholm
Copy link
Member

Nyholm commented Nov 30, 2020

Awesome!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants