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

FileUpload::getSanitizedName returns wrong file extension #239

Open
hubipe opened this issue Jun 26, 2024 · 2 comments
Open

FileUpload::getSanitizedName returns wrong file extension #239

hubipe opened this issue Jun 26, 2024 · 2 comments

Comments

@hubipe
Copy link

hubipe commented Jun 26, 2024

Version: 3.3.0

Bug Description

When uploading file.xls, method getSanitizedName() returns file.doc instead of file.xls.

Steps To Reproduce

Create a file upload and upload Microsoft Excel file with the old extension .xls. Dump FileUpload::getSanitizedName().

Expected Behavior

Method for returning sanitize name should return file.xls

Possible Solution

I've noticed, that the behavior of this method changed in the 3.2.4. The intention of the change was probably to return the correct extension for the image file uploads, but this change broke backwards compatibility for other types of files. Possible solution is to use finfo_file only for images?

@kuty
Copy link

kuty commented Sep 16, 2024

I can confirm, this "improvement" is causing a lot of troubles.. in our case e.g. .xlsm is saved as .xlsx and much more. It is also not possible to disable this magic.

@dg - d7cc833

@hubipe
Copy link
Author

hubipe commented Oct 17, 2024

Shall I prepare a PR for the suggested solution?
I had to cap nette/http to the version 3.2.3. But there is already version 3.3. Either I have to update an application to stop using getSanitizedName() or fix this issue.
So the question is - is this behavior stay as is or this change is unintended?

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

No branches or pull requests

2 participants