Fix #3917: Uploads: validate file before resizing/distributing.

This commit is contained in:
evazion
2018-09-22 17:13:30 -05:00
parent 39f9e01b13
commit 39fe5273a9
3 changed files with 28 additions and 27 deletions

View File

@@ -66,9 +66,15 @@ class UploadService
w, h = calculate_ugoira_dimensions(file.path)
yield(w, h)
else
elsif upload.is_image? || upload.is_flash?
image_size = ImageSpec.new(file.path)
yield(image_size.width, image_size.height)
elsif upload.file_ext == "bin"
yield(0, 0)
else
raise ArgumentError, "unhandled file type (#{upload.file_ext})" # should not happen
end
end
@@ -141,6 +147,7 @@ class UploadService
upload.image_height = height
end
upload.validate!(:file)
upload.tag_string = "#{upload.tag_string} #{Utils.automatic_tags(upload, file)}"
preview_file, crop_file, sample_file = Utils.generate_resizes(file, upload)