Merge pull request #2028 from okriuchykhin/ok_SCI_3817

Make previewable document filter more strict [SCI-3817]
This commit is contained in:
Alex Kriuchykhin 2019-09-04 15:40:01 +02:00 committed by GitHub
commit 77a1df0068
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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