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

Improve MIME type handling on File Upload and in Message Component #688

Merged
merged 8 commits into from
Aug 14, 2022

Conversation

Thumbscrew
Copy link
Contributor

@Thumbscrew Thumbscrew commented Jul 18, 2022

Description

Currently if you upload a file with MIME type prefixes video/, audio/ or image/ that is not in the ALLOWED_BLOB_MIMETYPES the file type will be converted to application/octet-stream by getBlobSafeMimeType. However, the React element used to display the file in the timeline is still a video, audio or image element. This appears to cancel the file upload and the file attachment shelf gets stuck on the screen.

Changes:

  • Move allowed MIME types to dedicated util file
  • Check that file type being uploaded is in the allowed blobs, if not upload as m.file
  • When building the Message component, check that the file is in the allowed blobs otherwise treat it as a generic file

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings

Preview: https://62f67680a954bc0932c98961--pr-cinny.netlify.app
⚠️ Exercise caution. Use test accounts. ⚠️

@Thumbscrew Thumbscrew changed the title Improve MIME type handling on File Upload Improve MIME type handling on File Upload and in Message Component Jul 18, 2022
@Thumbscrew Thumbscrew marked this pull request as ready for review August 10, 2022 21:16
@Thumbscrew
Copy link
Contributor Author

Thumbscrew commented Aug 10, 2022

You can test this by uploading an .mkv file which has MIME type video/x-matroska which is not in the allowed blobs list. Before this change, the upload shelf would get stuck and the file would not upload. Now it should upload as a generic file.

@ajbura ajbura merged commit a417980 into cinnyapp:dev Aug 14, 2022
ginnyTheCat pushed a commit to ginnyTheCat/cinny that referenced this pull request Aug 14, 2022
…innyapp#688)

* move allowed MIME types to own util file

* add check for safe MIME type before choosing how to upload

* check for allowed blob type to decide what component to load

* re-add check for safe mimetype

* fix bracket positioning
@Thumbscrew Thumbscrew deleted the improve-mimetype-handling branch August 14, 2022 12:46
NovaAndrom3da pushed a commit to NovaAndrom3da/neocinny that referenced this pull request Nov 23, 2023
…innyapp#688)

* move allowed MIME types to own util file

* add check for safe MIME type before choosing how to upload

* check for allowed blob type to decide what component to load

* re-add check for safe mimetype

* fix bracket positioning
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

Successfully merging this pull request may close these issues.

None yet

2 participants