uploads: fix it being possible to upload .mkv files as .webm.

Fix it being possible to upload arbitrary .mkv files and have them
be treated as .webm. This was possible because WebM uses the Matroska
container format, and we only checked for the Matroska header, not that
the file was actually a WebM.

There were only 6 such files in production:

* https://danbooru.donmai.us/posts?tags=exif:Matroska:DocType=matroska
* https://danbooru.donmai.us/posts/5522036
* https://danbooru.donmai.us/posts/4743498
* https://danbooru.donmai.us/posts/3925427
* https://danbooru.donmai.us/posts/3147897
* https://danbooru.donmai.us/posts/2965862
* https://danbooru.donmai.us/posts/2430436

These videos are playable in Chrome, but not in Firefox, since Firefox
doesn't support .mkv files (it supports some, depending on which codecs
are used, but not .mkv files in general).
This commit is contained in:
evazion
2022-10-25 19:21:32 -05:00
parent 6413b9abcd
commit df0e9bc4a7
8 changed files with 38 additions and 9 deletions

View File

@@ -20,7 +20,7 @@ class PostPreviewComponentTest < ViewComponent::TestCase
context "for a video post" do
should "render" do
@post = create(:post_with_file, filename: "test-512x512.webm").reload
@post = create(:post_with_file, filename: "webm/test-512x512.webm").reload
node = render_preview(@post, current_user: User.anonymous)
assert_equal(post_path(@post), node.css("article a").attr("href").value)