Defect #31365 » 31365_mail_gem_broken_subject.patch
config/initializers/10-patches.rb | ||
---|---|---|
107 | 107 | |
108 | 108 |
require 'mail' |
109 | 109 | |
110 |
module Mail |
|
111 |
class SubjectField |
|
112 |
def initialize(value = nil, charset = 'utf-8') |
|
113 |
if mime_encode = /^(=\?\S+\?\S\?)/.match(value).to_a[1] |
|
114 |
value.gsub!(/\?=\s+#{Regexp.escape(mime_encode)}/, '') |
|
115 |
end |
|
116 |
self.charset = charset |
|
117 |
super(CAPITALIZED_FIELD, value, charset) |
|
118 |
end |
|
119 |
end |
|
120 |
end |
|
121 | ||
110 | 122 |
module DeliveryMethods |
111 | 123 |
class TmpFile |
112 | 124 |
def initialize(*args); end |
test/fixtures/mail_handler/ticket_with_split_bytes_subject.eml | ||
---|---|---|
1 |
Date: Mon, 13 May 2019 13:39:29 +0900 |
|
2 |
Message-ID: <CALXUZfgwpW-hizEabSAjjkykQGV6-V6bwKu693Cr7cDH6DR7pQ@mail.gmail.com> |
|
3 |
Subject: =?utf-8?B?zrHOss6zzrTOtc62zrfOuM65zrrOu868zr3Ovs6/z4DPgc+Cz4PPhM+Fz4bP?= |
|
4 |
=?utf-8?B?h8+Iz4k=?= |
|
5 |
From: <foo@example.com> |
|
6 |
To: <baz@example.com> |
|
7 |
Content-Type: text/plain |
|
8 |
|
|
9 |
Split bytes subject. |
test/unit/mail_handler_test.rb | ||
---|---|---|
1136 | 1136 |
assert_equal issue.subject, 'New ticket on a given project with a very long subject line which exceeds 255 chars and should not be ignored but chopped off. And if the subject line is still not long enough, we just add more text. And more text. Wow, this is really annoying. Especially, if you have nothing to say...'[0,255] |
1137 | 1137 |
end |
1138 | 1138 | |
1139 |
def test_email_with_split_bytes_subject |
|
1140 |
issue = submit_email( |
|
1141 |
'ticket_with_split_bytes_subject.eml', |
|
1142 |
:issue => {:project => 'ecookbook'}, |
|
1143 |
:no_permission_check => '1', |
|
1144 |
:unknown_user => 'accept' |
|
1145 |
) |
|
1146 |
assert issue.is_a?(Issue) |
|
1147 |
assert_equal 'αβγδεζηθικλμνξοπρςστυφχψω', issue.subject |
|
1148 |
end |
|
1149 | ||
1139 | 1150 |
def test_first_keyword_should_be_matched |
1140 | 1151 |
issue = submit_email('ticket_with_duplicate_keyword.eml', :allow_override => 'priority') |
1141 | 1152 |
assert issue.is_a?(Issue) |
- « Previous
- 1
- 2
- Next »