Supporting encodings of iconv on Ruby 1.8 depend on iconv implementation. glibc-common-2.12-1.132 on CentOS6 does not support ks_c_5601-1987. Contributed by Felix Schäfer. git-svn-id: http://svn.redmine.org/redmine/trunk@12474 e93f8b46-1217-0410-a6f0-8f06a7374b81tags/2.5.0
@@ -410,7 +410,11 @@ class MailHandler < ActionMailer::Base | |||
part.header[:content_disposition].try(:disposition_type) == 'attachment' | |||
end | |||
@plain_text_body = parts.map {|p| Redmine::CodesetUtil.to_utf8(p.body.decoded, p.charset)}.join("\r\n") | |||
@plain_text_body = parts.map do |p| | |||
body_charset = p.charset.respond_to?(:force_encoding) ? | |||
Mail::RubyVer.pick_encoding(p.charset).to_s : p.charset | |||
Redmine::CodesetUtil.to_utf8(p.body.decoded, body_charset) | |||
end.join("\r\n") | |||
# strip html tags and remove doctype directive | |||
if parts.any? {|p| p.mime_type == 'text/html'} |
@@ -0,0 +1,14 @@ | |||
From: John Smith <JSmith@somenet.foo> | |||
To: "redmine@somenet.foo" <redmine@somenet.foo> | |||
Subject: This is a test | |||
Content-Type: multipart/alternative; | |||
boundary="_c20d9cfa-d16a-43a3-a7e5-71da7877ab23_" | |||
--_c20d9cfa-d16a-43a3-a7e5-71da7877ab23_ | |||
Content-Type: text/plain; charset="ks_c_5601-1987" | |||
Content-Transfer-Encoding: base64 | |||
sO24v73AtM+02S4= | |||
--_c20d9cfa-d16a-43a3-a7e5-71da7877ab23_-- | |||
@@ -538,6 +538,23 @@ class MailHandlerTest < ActiveSupport::TestCase | |||
assert_equal ja, issue.subject | |||
end | |||
def test_add_issue_with_korean_body | |||
# Make sure mail bodies with a charset unknown to Ruby | |||
# but known to the Mail gem 2.5.4 are handled correctly | |||
kr = "\xEA\xB3\xA0\xEB\xA7\x99\xEC\x8A\xB5\xEB\x8B\x88\xEB\x8B\xA4." | |||
if !kr.respond_to?(:force_encoding) | |||
puts "\nOn Ruby 1.8, skip Korean encoding mail body test" | |||
else | |||
kr.force_encoding('UTF-8') | |||
issue = submit_email( | |||
'body_ks_c_5601-1987.eml', | |||
:issue => {:project => 'ecookbook'} | |||
) | |||
assert_kind_of Issue, issue | |||
assert_equal kr, issue.description | |||
end | |||
end | |||
def test_add_issue_with_no_subject_header | |||
issue = submit_email( | |||
'no_subject_header.eml', |