From c65c0cf356cc13e7dc32883995f00363a086ae42 Mon Sep 17 00:00:00 2001 From: Oleksii Kriuchykhin Date: Wed, 4 Sep 2019 10:39:04 +0200 Subject: [PATCH] Make previewable document filter more strict [SCI-3817] --- config/initializers/paperclip.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/config/initializers/paperclip.rb b/config/initializers/paperclip.rb index 7ac23bbe9..a8ad4e64f 100644 --- a/config/initializers/paperclip.rb +++ b/config/initializers/paperclip.rb @@ -63,9 +63,11 @@ Paperclip::Attachment.class_eval do end def previewable_document? - previewable = Constants::PREVIEWABLE_FILE_TYPES.include?(content_type) + extensions = %w(.txt .pdf .xlsx .docx .pptx .xls .rtf .doc .ppt .odt .ods .odp) + + previewable = Constants::PREVIEWABLE_FILE_TYPES.include?(content_type) && + extensions.include?(File.extname(original_filename)) - extensions = %w(.xlsx .docx .pptx .xls .doc .ppt) # Mimetype sometimes recognizes Office files as zip files # In this case we also check the extension of the given file # Otherwise the conversion should fail if the file is being something else