From 4deb8aeea227240e444a0bed123407d83b5a1d4f Mon Sep 17 00:00:00 2001 From: evazion Date: Wed, 31 Mar 2021 20:47:35 -0500 Subject: [PATCH] uploads: disallow uploading new Flash files. Flash is dead. It's no longer supported by browsers, it's not well-supported by emulators, and only two Flash posts were uploaded in the last year anyway. Old Flash files will continue to exist, but new Flash uploads will no longer be allowed. --- app/models/upload.rb | 4 ++-- app/views/uploads/new.html.erb | 2 +- test/functional/uploads_controller_test.rb | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/models/upload.rb b/app/models/upload.rb index cfe822956..ff3bbbba5 100644 --- a/app/models/upload.rb +++ b/app/models/upload.rb @@ -13,8 +13,8 @@ class Upload < ApplicationRecord end def validate_file_ext(record) - if record.file_ext == "bin" - record.errors.add(:file_ext, "is invalid (only JPEG, PNG, GIF, SWF, MP4, and WebM files are allowed") + if record.file_ext.in?(["bin", "swf"]) + record.errors.add(:file_ext, "is invalid (only JPEG, PNG, GIF, MP4, and WebM files are allowed") end end diff --git a/app/views/uploads/new.html.erb b/app/views/uploads/new.html.erb index 9b2b9ae1b..7d50b9a70 100644 --- a/app/views/uploads/new.html.erb +++ b/app/views/uploads/new.html.erb @@ -31,7 +31,7 @@
Click or drag and drop to upload a file
-
Max size: <%= number_to_human_size(Danbooru.config.max_file_size) %>. Supported filetypes: jpg, png, gif, swf, mp4, webm.
+
Max size: <%= number_to_human_size(Danbooru.config.max_file_size) %>. Supported filetypes: jpg, png, gif, mp4, webm.
diff --git a/test/functional/uploads_controller_test.rb b/test/functional/uploads_controller_test.rb index e60ba4e0d..77bc57388 100644 --- a/test/functional/uploads_controller_test.rb +++ b/test/functional/uploads_controller_test.rb @@ -287,7 +287,7 @@ class UploadsControllerTest < ActionDispatch::IntegrationTest should_upload_successfully("test/files/test-animated-86x52.gif") should_upload_successfully("test/files/test-300x300.mp4") should_upload_successfully("test/files/test-512x512.webm") - should_upload_successfully("test/files/compressed.swf") + # should_upload_successfully("test/files/compressed.swf") end context "uploading a file from a source" do