@@ -0,0 +1,11 | |||
|
1 | Content-Type: application/ms-tnef; name="winmail.dat" | |
|
2 | Content-Transfer-Encoding: binary | |
|
3 | From: John Smith <JSmith@somenet.foo> | |
|
4 | To: "redmine@somenet.foo" <redmine@somenet.foo> | |
|
5 | Subject: =?iso-8859-1?Q?Testmail_from_Webmail:_=E4_=F6_=FC...?= | |
|
6 | Date: Fri, 1 Jun 2012 14:39:38 +0200 | |
|
7 | Message-ID: <87C31D42249DD0489D1A1444E3232DD7019D6183@foo.bar> | |
|
8 | Accept-Language: de-CH, en-US | |
|
9 | Content-Language: de-CH | |
|
10 | ||
|
11 | Fixture |
@@ -163,7 +163,7 class MailHandler < ActionMailer::Base | |||
|
163 | 163 | issue = Issue.new(:author => user, :project => project) |
|
164 | 164 | issue.safe_attributes = issue_attributes_from_keywords(issue) |
|
165 | 165 | issue.safe_attributes = {'custom_field_values' => custom_field_values_from_keywords(issue)} |
|
166 |
issue.subject = |
|
|
166 | issue.subject = cleaned_up_subject | |
|
167 | 167 | if issue.subject.blank? |
|
168 | 168 | issue.subject = '(no subject)' |
|
169 | 169 | end |
@@ -223,7 +223,7 class MailHandler < ActionMailer::Base | |||
|
223 | 223 | end |
|
224 | 224 | |
|
225 | 225 | if !message.locked? |
|
226 |
reply = Message.new(:subject => |
|
|
226 | reply = Message.new(:subject => cleaned_up_subject.gsub(%r{^.*msg\d+\]}, '').strip, | |
|
227 | 227 | :content => cleaned_up_text_body) |
|
228 | 228 | reply.author = user |
|
229 | 229 | reply.board = message.board |
@@ -364,6 +364,23 class MailHandler < ActionMailer::Base | |||
|
364 | 364 | cleanup_body(plain_text_body) |
|
365 | 365 | end |
|
366 | 366 | |
|
367 | def cleaned_up_subject | |
|
368 | subject = email.subject.to_s | |
|
369 | unless subject.respond_to?(:encoding) | |
|
370 | # try to reencode to utf8 manually with ruby1.8 | |
|
371 | begin | |
|
372 | if h = email.header[:subject] | |
|
373 | if m = h.value.match(/^=\?([^\?]+)\?/) | |
|
374 | subject = Redmine::CodesetUtil.to_utf8(subject, m[1]) | |
|
375 | end | |
|
376 | end | |
|
377 | rescue | |
|
378 | # nop | |
|
379 | end | |
|
380 | end | |
|
381 | subject.strip[0,255] | |
|
382 | end | |
|
383 | ||
|
367 | 384 | def self.full_sanitizer |
|
368 | 385 | @full_sanitizer ||= HTML::FullSanitizer.new |
|
369 | 386 | end |
@@ -347,6 +347,15 class MailHandlerTest < ActiveSupport::TestCase | |||
|
347 | 347 | assert_equal 'caaf384198bcbc9563ab5c058acd73cd', attachment.digest |
|
348 | 348 | end |
|
349 | 349 | |
|
350 | def test_add_issue_with_iso_8859_1_subject | |
|
351 | issue = submit_email( | |
|
352 | 'subject_as_iso-8859-1.eml', | |
|
353 | :issue => {:project => 'ecookbook'} | |
|
354 | ) | |
|
355 | assert_kind_of Issue, issue | |
|
356 | assert_equal 'Testmail from Webmail: ä ö ü...', issue.subject | |
|
357 | end | |
|
358 | ||
|
350 | 359 | def test_should_ignore_emails_from_locked_users |
|
351 | 360 | User.find(2).lock! |
|
352 | 361 |
General Comments 0
You need to be logged in to leave comments.
Login now