diff --git a/app/models/import.rb b/app/models/import.rb index caf673e9a..2f3864517 100644 --- a/app/models/import.rb +++ b/app/models/import.rb @@ -72,6 +72,7 @@ class Import < ApplicationRecord content = read_file_head separator = [',', ';'].max_by {|sep| content.count(sep)} + newline = content.index("\r\n") ? "\r\n" : '' # blank means auto wrapper = ['"', "'"].max_by {|quote_char| content.count(quote_char)} guessed_encoding = Redmine::CodesetUtil.guess_encoding(content) @@ -89,6 +90,7 @@ class Import < ApplicationRecord self.settings.merge!( 'separator' => separator, + 'newline' => newline, 'wrapper' => wrapper, 'encoding' => encoding, 'date_format' => date_format, @@ -270,6 +272,8 @@ class Import < ApplicationRecord csv_options[:encoding] = 'bom|UTF-8' if csv_options[:encoding] == 'UTF-8' separator = settings['separator'].to_s csv_options[:col_sep] = separator if separator.size == 1 + newline = setting['newline'].to_s + csv_options[:row_sep] = newline if newline.present? wrapper = settings['wrapper'].to_s csv_options[:quote_char] = wrapper if wrapper.size == 1