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

fix(Upload): fix handling of file types in combination with file extension #1986

Merged
merged 1 commit into from
Feb 13, 2023

Conversation

tujoworker
Copy link
Member

@tujoworker tujoworker commented Feb 11, 2023

This PR is based on #1824

Before, we did mix file extension and file mime type:
Screenshot 2023-02-11 at 13 55 34

Now it uses what ever is defined in the acceptedFileTypes={['txt']}:
Screenshot 2023-02-11 at 13 56 08

Now it uses what ever is defined in the acceptedFileTypes={['text/plain']}:
Screenshot 2023-02-11 at 13 56 24

@tujoworker tujoworker requested a review from AadneRo February 11, 2023 12:59
@codesandbox-ci
Copy link

codesandbox-ci bot commented Feb 11, 2023

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 84a3045:

Sandbox Source
eufemia-starter Configuration

@gatsby-cloud
Copy link

gatsby-cloud bot commented Feb 11, 2023

✅ DNB Eufemia Portal deploy preview ready

@tujoworker tujoworker added this to the v9 milestone Feb 11, 2023
@langz
Copy link
Contributor

langz commented Feb 12, 2023

Gave it a quick test, and found out that if acceptedFileTypes is something like the value a/e or e/a, I can select any files in the "filepicker", like a jpg, as seen in the following screenshots:

image

image

Not sure if this is intended or not, but it's at least an observation/diff from existing functionality deployed to https://eufemia.dnb.no/

@tujoworker tujoworker requested a review from langz February 12, 2023 18:18
@tujoworker
Copy link
Member Author

tujoworker commented Feb 13, 2023

Not sure if this is intended or not, but it's at least an observation/diff from existing functionality deployed to https://eufemia.dnb.no/

The diff is, now, when a slash is given, we do not add a dot. Before we added a dot, even if foo/bar was given. The browser then did think, ohh, .foo/bar is an extension. But now it gets foo/bar, and because its not a valid MIME on your system, then it lets you select everything. But we still have a check in place. We simply compare if the given file MIME is allowed, defined by the acceptedFileTypes list.

@tujoworker tujoworker force-pushed the fix/upload-file-extension-correction branch from 0ef1805 to 5d37d61 Compare February 13, 2023 09:26
@tujoworker tujoworker force-pushed the fix/upload-file-extension-correction branch from 5d37d61 to 84a3045 Compare February 13, 2023 09:32
@tujoworker tujoworker merged commit 3fd9bfa into main Feb 13, 2023
@tujoworker tujoworker deleted the fix/upload-file-extension-correction branch February 13, 2023 11:51
tujoworker pushed a commit that referenced this pull request Feb 13, 2023
## [9.47.1](v9.47.0...v9.47.1) (2023-02-13)

### Bug Fixes

* **InputMasked:** avoid inherit mask options and types when custom mask is used ([#1988](#1988)) ([8937bcc](8937bcc))
* **InputMasked:** fix negative value updates (number mask) ([#1792](#1792)) ([e2b9482](e2b9482))
* **Upload:** fix handling of file types in combination with file extension ([#1986](#1986)) ([3fd9bfa](3fd9bfa))
@tujoworker
Copy link
Member Author

🎉 This PR is included in version 9.47.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Successfully merging this pull request may close these issues.

2 participants