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

[Extension] Issue with csv extension which can be carried with application/vnd.ms-excel or text/plain content type #116

Open
Mth0158 opened this issue Nov 13, 2024 · 0 comments

Comments

@Mth0158
Copy link

Mth0158 commented Nov 13, 2024

Hi,

Maintainer of active_storage_validations here 👋.

We are relying on the amazing marcel gem to do the heavy-lifting of mapping content types and extensions. However there seem to have an issue with the csv extension. Issue link => igorkasyanchuk/active_storage_validations#291.

It seems that a .csv file can have a text/csv, application/vnd.ms-excel or text/plain content type depending on the client's OS. As mentioned by @jessie19:

TL;DR On a Windows machine with Microsoft Excel installed, CSV files may have a MIME type of application/vnd.ms-excel rather than the RFC 4180 suggested type of text/csv. Symfony, in particular, will match that MIME type with an file extension of ‘xls’. That causes issues with file validation.

source: https://christianwood.net/posts/csv-file-upload-validation/

I am unsure about what to do here, we could extend marcel with something like:

Marcel::MimeType.extend "application/vnd.ms-excel", extensions: %(csv)
Marcel::MimeType.extend "text/plain", extensions: %(csv)

But it could have side effects down the road, are you aware of this issue? @jeremy

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

1 participant