Project

General

Profile

Defect #28689 » 28689-v2.diff

patch (also supports Ruby 2.2) - Go MAEDA, 2018-05-06 07:31

View differences:

Gemfile (working copy)
13 13
gem "roadie", "~> 3.2.1"
14 14
gem "mimemagic"
15 15
gem "mail", "~> 2.6.4"
16
gem "csv", "~> 1.0.1" if RUBY_VERSION >= "2.5"
16
gem "csv", "~> 1.0.2" if RUBY_VERSION >= "2.3"
17 17

  
18 18
gem "nokogiri", "~> 1.8.0"
19 19
gem "i18n", "~> 0.7.0"
app/controllers/imports_controller.rb (working copy)
50 50
      redirect_to import_mapping_path(@import)
51 51
    end
52 52

  
53
  rescue CSV::MalformedCSVError => e
54
    flash.now[:error] = l(:error_invalid_csv_file_or_settings)
55
  rescue ArgumentError, EncodingError => e
56
    flash.now[:error] = l(:error_invalid_file_encoding, :encoding => ERB::Util.h(@import.settings['encoding']))
53
  # TODO: Remove ArgumentError when support for Ruby 2.2 is dropped (#28689)
54
  rescue CSV::MalformedCSVError, ArgumentError, EncodingError => e
55
    if e.is_a?(CSV::MalformedCSVError) && e.message !~ /Invalid byte sequence/
56
      flash.now[:error] = l(:error_invalid_csv_file_or_settings)
57
    else
58
      flash.now[:error] = l(:error_invalid_file_encoding, :encoding => ERB::Util.h(@import.settings['encoding']))
59
    end
57 60
  rescue SystemCallError => e
58 61
    flash.now[:error] = l(:error_can_not_read_import_file)
59 62
  end
(2-2/2)