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

Check filename extension to determine file type #4474

Closed
ebruchez opened this issue Mar 19, 2020 · 5 comments
Closed

Check filename extension to determine file type #4474

ebruchez opened this issue Mar 19, 2020 · 5 comments

Comments

@ebruchez
Copy link
Collaborator

We have #1838 about doing content sniffing, but that is a more elaborate fix to do.

Right now, we use the Content-Type header, which we know we cannot trust. Along the same lines, we know we cannot trust a file's extension. However, right now, if the browser doesn't provide a useful Content-Type, we don't check the extension either.

So the idea would be, until we can do #1838, to use the file extension to determine the mediatype, either always, or when we don't get a useful Content-Type from the browser.

+1 from customer

@ebruchez ebruchez self-assigned this Mar 19, 2020
@ebruchez ebruchez added this to To review in Orbeon Forms 2020.1 via automation Mar 21, 2020
@ebruchez ebruchez moved this from To review to In progress in Orbeon Forms 2020.1 Mar 21, 2020
@ebruchez
Copy link
Collaborator Author

ebruchez commented Mar 21, 2020

  • implement
  • tests
  • backport to 2019.2.1 customer branch
  • backport to 2018.2.4 customer branch

ebruchez pushed a commit that referenced this issue Mar 25, 2020
- update some common types
- add new common types
- reorganize
Orbeon Forms 2020.1 automation moved this from In progress to Done Mar 25, 2020
@ebruchez
Copy link
Collaborator Author

ebruchez commented Mar 26, 2020

We produce a mediatype based on the file extension in those cases where the browser doesn't doesn't send the correct mediatype. This mediatype is stored, and used to validate the mediatype on the server when we use a "Supported Files Types" validation.

However, when using a "Supported Files Types" validation, we also output an accept attribute on the <input type="file"> element. I wondered if this would cause a problem.

With Chrome, Safari, and Firefox on Mac, at least, it seems that when the browser doesn't know the mediatype, it proposes all files in the file selector, which is good. This is the case with application/vnd.ms-outlook, for example

I was thinking that, if this was not the case with all browsers, we could also output an extension in the accept attribute. See this SO question.

For now, I am not sure we need to do anything given the above.

@avernet
Copy link
Collaborator

avernet commented Jun 6, 2020

@ebruchez Is this new behavior documented? IMHO, this is also blog-worthy. (Should have a "blog-worthy" tag?)

@ebruchez
Copy link
Collaborator Author

ebruchez commented Jun 8, 2020

Just now documented.

We have a list of possible blog posts in our recurring calendar entry. Not sure if a label is necessary?

@avernet
Copy link
Collaborator

avernet commented Jun 8, 2020

👍 for the doc; and no need for a tag if we have a list somewhere.

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

No branches or pull requests

2 participants