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

MKV file upload failure while it works on classic editor #8873

Closed
arunsathiya opened this issue Aug 11, 2018 · 10 comments
Closed

MKV file upload failure while it works on classic editor #8873

arunsathiya opened this issue Aug 11, 2018 · 10 comments
Labels
Backwards Compatibility Issues or PRs that impact backwards compatability [Block] File Affects the File Block [Feature] Blocks Overall functionality of blocks [Feature] Media Anything that impacts the experience of managing media

Comments

@arunsathiya
Copy link
Contributor

Describe the bug: MKV file upload fails on the Gutenberg editor with a Sorry, this file type is not permitted for security reasons. reason while it uploads fine on the classic editor. Clearly the WordPress instance accepts this file as it uploads fine on the classic editor and the media library page.

Steps to reproduce the behavior:

  • Open a post with Gutenberg editor
  • Drag and drop a .mkv video file
  • Notice that a file block is created
  • Notice the Sorry, this file type is not permitted for security reasons. is shown on that file block

Expected behavior: The file uploads fine and shows up on the file block.

Screenshots and GIF indicating this behavior

screen shot 2018-08-11 at 17 55 27

screen capture on 2018-08-11 at 17 38 33

Desktop (please complete the following information): WordPress 4.9.8 and Gutenberg 3.5.0 using Google Chrome Version 68.0.3440.84 (Official Build) (64-bit) on macOS 10.13.6

@arunsathiya
Copy link
Contributor Author

Just to note, the file upload fails on the file block, and it's not uploaded to the media library region either.

Just looked at the media library region and it's not seen there - meaning, it's not uploaded at all.

@arunsathiya
Copy link
Contributor Author

Indication that .mkv file upload was fine on the classic editor.

GIF recording:

screen capture on 2018-08-11 at 17 36 19

@designsimply
Copy link
Member

Tested and confirmed that I cannot drag an .mkv file into a post to upload it or upload an .mkv file via a video block using WordPress 4.9.8 and Gutenberg 3.5.0 and Firefox 61.0.2 on macOS 10.13.6 with the testing steps provided.

Sample file: https://github.com/Matroska-Org/matroska-test-files/blob/master/test_files/test1.mkv

There were no errors in the browser console during my test and the only possibly-relevant thing I could find in the Network tab is that the autosave had a blob in the raw and rendered content (screenshot). If I refresh the post just after uploading, the block is replaced with an error that says This block has encountered an error and cannot be previewed and the console shows a TypeError: "e is undefined" error for react-dom.min.82e21c65.js:110:57 (screenshot).

I also found that I was able to upload an .mkv file using the Media Library option and then dragging the .mkv file into the media modal, however, it results in an error that says:

No video with supported format and MIME type found.

screen shot 2018-08-13 at mon aug 13 11 33 17 pm
Seen at http://alittletestblog.com/wp-admin/post.php?post=14234&action=edit running WordPress 4.9.8 and Gutenberg 3.5.0 using Firefox 61.0.2 on macOS 10.13.6.

After testing :) I noticed that https://codex.wordpress.org/Uploading_Files lists which file types are supported and .mkv files are not listed.

WordPress supports uploading the following file types:

Video

.mp4, .m4v (MPEG-4)
.mov (QuickTime)
.wmv (Windows Media Video)
.avi
.mpg
.ogv (Ogg)
.3gp (3GPP)
.3g2 (3GPP2)

Not all webhosts permit these files to be uploaded. Also, they may not permit large file uploads. If you are having issues, please check with your host first.

In your classic editor example, I see that uploading an .mkv results in a successful file upload and a link to the file (the video is not embedded into a player), so I'm assuming you're expecting the same behavior in Gutenberg (perhaps a link to the file in a file block?).

@designsimply designsimply added [Type] Enhancement A suggestion for improvement. [Feature] Blocks Overall functionality of blocks labels Aug 14, 2018
@arunsathiya
Copy link
Contributor Author

I'm assuming you're expecting the same behavior in Gutenberg (perhaps a link to the file in a file block?

Yes, I could say that's what I am hoping to see ATM. But, if WordPress does not support MKV files, it would not make sense for this file to appear as a file block.

Rather it would make sense to appear in a format that it does right now - just a link.

Although the link being broken is another concern that might need to be addressed.

@aduth
Copy link
Member

aduth commented May 31, 2019

In testing this, I can reproduce the security warning which shows upon upload. This makes sense given file upload restrictions. However, it would also make sense that this would be restricted in the Classic Editor as well. And indeed, in my testing, I see a similar notice, contrary to what was reported here.

image

Is it possible that you have some plugin which extends the default set of allowable file types?

@aduth aduth added [Block] File Affects the File Block [Status] Needs More Info Follow-up required in order to be actionable. Backwards Compatibility Issues or PRs that impact backwards compatability and removed [Type] Enhancement A suggestion for improvement. labels May 31, 2019
@rolandinsh
Copy link

Just another note: seems like .doc & .xls also can't be uploaded via file block, but is possible via adding new media (/wp-admin/media-new.php)

@milesdelliott
Copy link
Contributor

( I think) A similar thing is happening with .stl files, I can upload through the media library, but not in a file block.

Looking through the source for the uploadMedia function, this particular error occurs when the fileType doesn't occur in the allowed mime types for user list.

I can check that list with get allowed mime types and I see that the stl extension appears in that list with the same mime type I get when I check on my computer. Still though it's not working

Even if the file upload doesn't work, the files you tried to upload are still viewable if you find the hidden input element. You can peek in and see what data is going into gutenberg, and for the .stl files the type key is missing.

So I don't know why the file type isn't getting added to the input, but it seems like it's evaluating to false, so that when mediaUpload checks to see if the type is in the allowed list it doesn't show up

@FlyingDR
Copy link

FlyingDR commented Oct 3, 2019

@aduth Please check Note section under example of use of File.type at MDN. It clearly states that browser can (and will) return empty string for File.type and strictly advises not to use this property as sole source of truth for file type checking.

For example .doc extension may not be known for a system that have no office application installed. It results into empty string for type property and hence to error message.

Please also refer Chromium bug 511895 as example of Chromium developers opinion, it generally matches to information listed at MDN.

Fix of this issue may require update of isAllowedMimeTypeForUser and related code to include check of file extension in a case if given file type is empty.

@swissspidy swissspidy added the [Feature] Media Anything that impacts the experience of managing media label Oct 4, 2019
@karmatosed karmatosed removed the [Status] Needs More Info Follow-up required in order to be actionable. label Mar 16, 2020
@Mamaduka
Copy link
Member

I can also confirm, that isAllowedMimeTypeForUser() check fails, even when the custom mime types are properly registered.

I only get the error message when using the drop zone or form file upload in the MediaPlaceholder component. Media Library modal works as expected.

@jordesign
Copy link
Contributor

In testing I was able to upload an MKV file into the Editor on WP6.2.2. Closing this as no longer able to replicate.

@jordesign jordesign closed this as not planned Won't fix, can't repro, duplicate, stale Aug 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Backwards Compatibility Issues or PRs that impact backwards compatability [Block] File Affects the File Block [Feature] Blocks Overall functionality of blocks [Feature] Media Anything that impacts the experience of managing media
Projects
None yet
Development

No branches or pull requests

10 participants