1
0
mirror of https://github.com/meineerde/redmine.git synced 2026-01-06 23:51:31 +00:00

Import UTF-8 issue CSV files with BOM and quoted strings (#30412).

Patch by Felix Schäfer.


git-svn-id: http://svn.redmine.org/redmine/trunk@17786 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Go MAEDA 2019-01-12 00:57:27 +00:00
parent bce44769ff
commit 0eb5d19a0c
2 changed files with 10 additions and 0 deletions

View File

@ -217,6 +217,7 @@ class Import < ActiveRecord::Base
csv_options = {:headers => false}
csv_options[:encoding] = settings['encoding'].to_s.presence || 'UTF-8'
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
wrapper = settings['wrapper'].to_s

View File

@ -116,6 +116,15 @@ class IssueImportTest < ActiveSupport::TestCase
assert_equal 2, issues[2].parent_id
end
def test_import_utf8_with_bom
import = generate_import_with_mapping('import_issues_utf8_with_bom.csv')
import.settings.merge!('encoding' => 'UTF-8')
import.save
issues = new_records(Issue,3) { import.run }
assert_equal 3, issues.count
end
def test_backward_and_forward_reference_to_parent_should_work
import = generate_import('import_subtasks.csv')
import.settings = {