Project

General

Profile

Defect #24910 » converter_not_found2.patch

Karel Pičman, 2020-09-17 14:37

View differences:

lib/redmine/codeset_util.rb (working copy)
end
enc = encoding.blank? ? "UTF-8" : encoding
if enc.casecmp("UTF-8") != 0
str.force_encoding(enc)
str = str.encode("UTF-8", :invalid => :replace,
begin
str.force_encoding(enc)
str = str.encode("UTF-8", :invalid => :replace,
:undef => :replace, :replace => '?')
rescue Encoding::ConverterNotFoundError
Rails.logger.warn ">>> ConverterNotFoundError (#{enc} to UTF-8)"
str = replace_invalid_utf8(str)
end
else
str = replace_invalid_utf8(str)
end
test/fixtures/mail_handler/body_windows-1258.eml (working copy)
From: John Smith <JSmith@somenet.foo>
To: "redmine@somenet.foo" <redmine@somenet.foo>
Subject: This is a Vietnamiese test
Content-Type: multipart/alternative;
boundary="_c20d9cfa-d16a-43a3-a7e5-71da7877ab23_"
--_c20d9cfa-d16a-43a3-a7e5-71da7877ab23_
Content-Type: text/plain; charset="windows-1258"
Content-Transfer-Encoding: quoted-printable
không hợp lệ
--_c20d9cfa-d16a-43a3-a7e5-71da7877ab23_--
test/unit/lib/redmine/codeset_util_test.rb (working copy)
assert_equal "UTF-8", s2.encoding.to_s
assert_equal 'こんにち?', s2
end
test "#to_utf8 should support not supported code page" do
s1 = (+'không hợp lệ').force_encoding('Windows-1258')
s2 = Redmine::CodesetUtil.to_utf8(s1, 'Windows-1258')
assert s2.valid_encoding?
assert_equal 'UTF-8', s2.encoding.to_s
assert_equal 'không hợp lệ', s2
end
end
test/unit/mail_handler_test.rb (working copy)
assert_equal '고맙습니다.', issue.description
end
def test_add_issue_with_vietnamiese_body
issue = submit_email(
'body_windows-1258.eml',
issue: { project: 'ecookbook' }
)
assert_kind_of Issue, issue
assert issue.description.include?('không hợp lệ')
end
def test_add_issue_with_no_subject_header
with_settings :default_language => 'en' do
issue = submit_email(
(2-2/2)