Commit d239f3d7 authored by jplang's avatar jplang

Fixed: German umlauts in Subject get striped with ruby1.8 (#11065).

git-svn-id: https://svn.redmine.org/redmine/trunk@9796 e93f8b46-1217-0410-a6f0-8f06a7374b81
parent 197036be
......@@ -163,7 +163,7 @@ class MailHandler < ActionMailer::Base
issue = Issue.new(:author => user, :project => project)
issue.safe_attributes = issue_attributes_from_keywords(issue)
issue.safe_attributes = {'custom_field_values' => custom_field_values_from_keywords(issue)}
issue.subject = email.subject.to_s.chomp[0,255]
issue.subject = cleaned_up_subject
if issue.subject.blank?
issue.subject = '(no subject)'
end
......@@ -223,7 +223,7 @@ class MailHandler < ActionMailer::Base
end
if !message.locked?
reply = Message.new(:subject => email.subject.gsub(%r{^.*msg\d+\]}, '').strip,
reply = Message.new(:subject => cleaned_up_subject.gsub(%r{^.*msg\d+\]}, '').strip,
:content => cleaned_up_text_body)
reply.author = user
reply.board = message.board
......@@ -364,6 +364,23 @@ class MailHandler < ActionMailer::Base
cleanup_body(plain_text_body)
end
def cleaned_up_subject
subject = email.subject.to_s
unless subject.respond_to?(:encoding)
# try to reencode to utf8 manually with ruby1.8
begin
if h = email.header[:subject]
if m = h.value.match(/^=\?([^\?]+)\?/)
subject = Redmine::CodesetUtil.to_utf8(subject, m[1])
end
end
rescue
# nop
end
end
subject.strip[0,255]
end
def self.full_sanitizer
@full_sanitizer ||= HTML::FullSanitizer.new
end
......
Content-Type: application/ms-tnef; name="winmail.dat"
Content-Transfer-Encoding: binary
From: John Smith <JSmith@somenet.foo>
To: "redmine@somenet.foo" <redmine@somenet.foo>
Subject: =?iso-8859-1?Q?Testmail_from_Webmail:_=E4_=F6_=FC...?=
Date: Fri, 1 Jun 2012 14:39:38 +0200
Message-ID: <87C31D42249DD0489D1A1444E3232DD7019D6183@foo.bar>
Accept-Language: de-CH, en-US
Content-Language: de-CH
Fixture
......@@ -347,6 +347,15 @@ class MailHandlerTest < ActiveSupport::TestCase
assert_equal 'caaf384198bcbc9563ab5c058acd73cd', attachment.digest
end
def test_add_issue_with_iso_8859_1_subject
issue = submit_email(
'subject_as_iso-8859-1.eml',
:issue => {:project => 'ecookbook'}
)
assert_kind_of Issue, issue
assert_equal 'Testmail from Webmail: ä ö ü...', issue.subject
end
def test_should_ignore_emails_from_locked_users
User.find(2).lock!
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment