Defect #24910 » converter_not_found2.patch
lib/redmine/codeset_util.rb (working copy) | ||
---|---|---|
23 | 23 |
end |
24 | 24 |
enc = encoding.blank? ? "UTF-8" : encoding |
25 | 25 |
if enc.casecmp("UTF-8") != 0 |
26 |
str.force_encoding(enc) |
|
27 |
str = str.encode("UTF-8", :invalid => :replace, |
|
26 |
begin |
|
27 |
str.force_encoding(enc) |
|
28 |
str = str.encode("UTF-8", :invalid => :replace, |
|
28 | 29 |
:undef => :replace, :replace => '?') |
30 |
rescue Encoding::ConverterNotFoundError |
|
31 |
Rails.logger.warn ">>> ConverterNotFoundError (#{enc} to UTF-8)" |
|
32 |
str = replace_invalid_utf8(str) |
|
33 |
end |
|
29 | 34 |
else |
30 | 35 |
str = replace_invalid_utf8(str) |
31 | 36 |
end |
test/fixtures/mail_handler/body_windows-1258.eml (working copy) | ||
---|---|---|
1 |
From: John Smith <JSmith@somenet.foo> |
|
2 |
To: "redmine@somenet.foo" <redmine@somenet.foo> |
|
3 |
Subject: This is a Vietnamiese test |
|
4 |
Content-Type: multipart/alternative; |
|
5 |
boundary="_c20d9cfa-d16a-43a3-a7e5-71da7877ab23_" |
|
6 | ||
7 |
--_c20d9cfa-d16a-43a3-a7e5-71da7877ab23_ |
|
8 |
Content-Type: text/plain; charset="windows-1258" |
|
9 |
Content-Transfer-Encoding: quoted-printable |
|
10 | ||
11 |
không hợp lệ |
|
12 | ||
13 |
--_c20d9cfa-d16a-43a3-a7e5-71da7877ab23_-- |
|
14 |
test/unit/lib/redmine/codeset_util_test.rb (working copy) | ||
---|---|---|
101 | 101 |
assert_equal "UTF-8", s2.encoding.to_s |
102 | 102 |
assert_equal 'こんにち?', s2 |
103 | 103 |
end |
104 | ||
105 |
test "#to_utf8 should support not supported code page" do |
|
106 |
s1 = (+'không hợp lệ').force_encoding('Windows-1258') |
|
107 |
s2 = Redmine::CodesetUtil.to_utf8(s1, 'Windows-1258') |
|
108 |
assert s2.valid_encoding? |
|
109 |
assert_equal 'UTF-8', s2.encoding.to_s |
|
110 |
assert_equal 'không hợp lệ', s2 |
|
111 |
end |
|
104 | 112 |
end |
test/unit/mail_handler_test.rb (working copy) | ||
---|---|---|
747 | 747 |
assert_equal '고맙습니다.', issue.description |
748 | 748 |
end |
749 | 749 | |
750 |
def test_add_issue_with_vietnamiese_body |
|
751 |
issue = submit_email( |
|
752 |
'body_windows-1258.eml', |
|
753 |
issue: { project: 'ecookbook' } |
|
754 |
) |
|
755 |
assert_kind_of Issue, issue |
|
756 |
assert issue.description.include?('không hợp lệ') |
|
757 |
end |
|
758 | ||
750 | 759 |
def test_add_issue_with_no_subject_header |
751 | 760 |
with_settings :default_language => 'en' do |
752 | 761 |
issue = submit_email( |
- « Previous
- 1
- 2
- Next »