Detect encoding of uploaded files and convert to UTF-8. Finally.
This commit is contained in:
1
Gemfile
1
Gemfile
@ -5,6 +5,7 @@ source 'https://rubygems.org'
|
||||
gem 'bcrypt'
|
||||
gem 'bootstrap-will_paginate'
|
||||
gem 'carrierwave'
|
||||
gem 'charlock_holmes', require: 'charlock_holmes/string'
|
||||
gem 'docker-api', require: 'docker'
|
||||
gem 'eventmachine'
|
||||
gem 'factory_bot_rails'
|
||||
|
@ -133,6 +133,7 @@ GEM
|
||||
marcel (~> 1.0.0)
|
||||
mini_mime (>= 0.1.3)
|
||||
ssrf_filter (~> 1.0)
|
||||
charlock_holmes (0.7.7)
|
||||
childprocess (3.0.0)
|
||||
chronic (0.10.2)
|
||||
coderay (1.1.3)
|
||||
@ -393,7 +394,7 @@ GEM
|
||||
rspec-mocks (~> 3.10)
|
||||
rspec-support (~> 3.10)
|
||||
rspec-support (3.10.2)
|
||||
rubocop (1.14.0)
|
||||
rubocop (1.15.0)
|
||||
parallel (~> 1.10)
|
||||
parser (>= 3.0.0.0)
|
||||
rainbow (>= 2.2.2, < 4.0)
|
||||
@ -525,6 +526,7 @@ DEPENDENCIES
|
||||
bootstrap-will_paginate
|
||||
capybara
|
||||
carrierwave
|
||||
charlock_holmes
|
||||
concurrent-ruby
|
||||
database_cleaner
|
||||
docker-api
|
||||
|
@ -218,7 +218,7 @@ user_id: current_user.id, user_type: current_user.class.name
|
||||
file_params[:content] = nil
|
||||
file_params[:native_file] = file_attributes[:content]
|
||||
else
|
||||
file_params[:content] = file_attributes[:content].read.encode.delete("\x00")
|
||||
file_params[:content] = file_attributes[:content].read.detect_encoding!.encode.delete("\x00")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user