From 2edaf874610fdf9ba2a7160de326511f680da49c Mon Sep 17 00:00:00 2001 From: Aleksei Burlakov Date: Tue, 26 Sep 2023 05:32:24 -0400 Subject: [PATCH] Fix mime type issue in MS windows This change should accompish the commits a4969be6 and 6544880e. Basically we make an exception for bzip2 files, in a way that they may come as octet stream. --- hawk/app/models/report.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/hawk/app/models/report.rb b/hawk/app/models/report.rb index 46f47ab6b..7cf047513 100644 --- a/hawk/app/models/report.rb +++ b/hawk/app/models/report.rb @@ -279,6 +279,11 @@ class Upload < Tableless attribute :upload, ActionDispatch::Http::UploadedFile validate do |record| + # Windows doens't understand bzip2 and sends them as octet-stream, + # so let's make an exception for bzip2 and let them be octet-stream. + if record.upload.content_type == "application/octet-stream" + next if record.upload.original_filename =~ /^[a-zA-Z0-9_-]+\.tar\.bz2\z/ + end unless ["application/gzip", "application/x-gzip", "application/x-bzip",