Defect #3592

Unreadable quoted-printable utf-8 long subject in some mail clients

Added by Stanislav German-Evtushenko over 8 years ago. Updated over 3 years ago.

Status:NewStart date:2009-07-07
Priority:NormalDue date:
Assignee:-% Done:

0%

Category:Email notifications
Target version:-
Resolution: Affected version:

Description

Subject becomes undreadable in groupwise 7.0.3 when it's quoted-printable and longer ~80 chars. This patch converts subject to base64 instead of quoted-printable.

mailer-subject-base64.patch Magnifier (511 Bytes) Stanislav German-Evtushenko, 2009-07-07 08:24

mailer-long-subject-base64.patch Magnifier - This patch converts subject to base64 and handles the 76 chars limit. (314 Bytes) Maxim Verevkin, 2010-02-12 09:43

mailresult.png - the subject of the mail has truned (15.2 KB) lee min, 2014-08-27 10:02


Related issues

Related to Redmine - Defect #8658: uncorrect subject on mail notification Closed 2011-06-21
Related to Redmine - Defect #16859: rdm-mailhandler: subject corruption New
Duplicated by Redmine - Defect #3601: Problem in issue subject and notification Closed 2009-07-09 2009-07-13
Duplicated by Redmine - Defect #17752: mail subject come to unreadable code when it's too long Closed

History

#1 Updated by Stanislav German-Evtushenko over 8 years ago

Here subject is for example:

Re: =?utf-8?Q?=5b=d0=97=d0=b0=d1=8f=d0=b2=d0=ba=d0=b8_=d0=b2_=d0=be=d1=82=d0=b4=d0=b5=d0=bb_IT_=2d_=d0=97=d0=b0=d1=8f=d0=b2=d0=ba=d0=b0_=23=39=36=5d_=d0=97=d0=b0=d0=ba=d0=b0=d0=b7_=d0=b2_=d0=bf=d1=80=d0=be=d0=b8=d0=b7=d0=b2=d0=be=d0=b4=d1=81=d1=82=d0=b2=d0=be_=e2=84=96_=38=34?=

#2 Updated by Konstantin Zaitsev over 8 years ago

Thank You, for patch

#3 Updated by Azamat Hackimov over 8 years ago

Looks good for me, but I'm going to try also with CJK-langs...

#4 Updated by Stanislav German-Evtushenko over 8 years ago

Huh, the problem is still unresolved. Base64 allows to put more chars in subject but there is a limit too. I have done some investigation and here what I found.
Thunderbird is doing something like that (it's displayed normaly in groupwise):

Subject: =?UT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Ig0YLQtdGB0YIg0YLQtdGB0YIg0YLQtdGB0YIg0YLQtdGB0YIg0YLQtdGB0YIg0YLQtdGB0YIg0YLQtdGB0YIg0YLQtdGB0YIg0YLQtdGB0YIg0YLQtdGB0YIg0YLQtdGB0YIg0YLQtdGB0YIg0YLQtdGB0YIg0YLQtdGB0YIg0YLQtdGB0YIg0YLQtdGB0YIg0YLQtdGB0YIg0YLQtdGB0YIg0YLQtdGB0YIg0YLQtdGB0YIg0YLQtdGB0YIg0YLQtdGB0YIg0YLQtdGB0YIg0YLQtdGB0YIg0YLQtdGB0YIg0YLQtdGB0YIK?=

or like that (quoted-printable):

Subject: =?UTF-8?Q?=5b=d0=97=d0=b0=d1=8f=d0=b2=d0=ba=d0=b8_=d0=b2_=d0=be=d1=82=d0=b4=d0=b5=d0=bb_IT_=2d_=d0=97=d0=b0=d1=8f=d0=b2=d0=ba=d0=b0_=23=39=36=5d_=d0=97=d0=b0=d0=ba=d0=b0=d0=b7_=d0=b2_=d0=bf=d1=80=d0=be=d0=b8=d0=b7=d0=b2=d0=be=d0=b4=d1=81=d1=82=d0=b2=d0=be_=e2=84=96_=38=34?=

Here extraction from RFC 2045 is:

    (5)   (Soft Line Breaks) The Quoted-Printable encoding
          REQUIRES that encoded lines be no more than 76
          characters long.  If longer lines are to be encoded
          with the Quoted-Printable encoding, "soft" line breaks
          must be used.  An equal sign as the last character on a
          encoded line indicates such a non-significant ("soft")
          line break in the encoded text.

   Thus if the "raw" form of the line is a single unencoded line that
   says:

     Now's the time for all folk to come to the aid of their country.

   This can be represented, in the Quoted-Printable encoding, as:

     Now's the time =
     for all folk to come=
      to the aid of their country.

   This provides a mechanism with which long lines are encoded in such a
   way as to be restored by the user agent.  The 76 character limit does
   not count the trailing CRLF, but counts all other characters,
   including any equal signs.

Could anyone offer right way how to get round this?
Does actionmailer code need to be changed or need to write own 'quoted-printable' converter for redmine?

#5 Updated by Kirill Ponomarev about 8 years ago

This patch does not resolve the problem for trunk r2924.
Can you update it?

#6 Updated by Maxim Verevkin almost 8 years ago

When Base64.encode64 is applied the result is the string splitted with CRLF. The patch decorates each line with '=?utf-8?B?' prefix and '?=' suffix.

#7 Updated by Stanislav German-Evtushenko almost 8 years ago

Maxim Verevkin wrote:

When Base64.encode64 is applied the result is the string splitted with CRLF. The patch decorates each line with '=?utf-8?B?' prefix and '?=' suffix.

Is it necessary to use both patches or just last one?

#8 Updated by Maxim Verevkin almost 8 years ago

Only the new patch works well for redmine v0.9.1. It completely solved the issue of unreadable UTF-8 subjects in email notifications for us.

#9 Updated by Stanislav German-Evtushenko almost 8 years ago

Maxim Verevkin wrote:

Only the new patch works well for redmine v0.9.1. It completely solved the issue of unreadable UTF-8 subjects in email notifications for us.

Does it for for quoted-printable subjects?

#10 Updated by Stanislav German-Evtushenko almost 8 years ago

Stanislav German-Evtushenko wrote:

Maxim Verevkin wrote:

Only the new patch works well for redmine v0.9.1. It completely solved the issue of unreadable UTF-8 subjects in email notifications for us.

Does it for for quoted-printable subjects?

Oh, it seems like it should work :)

#11 Updated by Stanislav German-Evtushenko almost 8 years ago

Maxim Verevkin wrote:

When Base64.encode64 is applied the result is the string splitted with CRLF. The patch decorates each line with '=?utf-8?B?' prefix and '?=' suffix.

Hm, documentation says that only '\n' adds after each 60 chars.

Encodes a string to its base 64 representation. Each 60 characters of output is separated by a newline character.

ActiveSupport::Base64.encode64("Original unencoded string")
# => "T3JpZ2luYWwgdW5lbmNvZGVkIHN0cmluZw==\n" 

http://api.rubyonrails.org/classes/ActiveSupport/Base64.html#M001381

#12 Updated by Stanislav German-Evtushenko almost 8 years ago

Maxim,
I got how it works. Sorry for stupid questions.
I my point of view it's not good to use hardcoded charset. I think better way is using #{charset}.

#13 Updated by Maxim Verevkin almost 8 years ago

Stanislav,

I my point of view it's not good to use hardcoded charset. I think better way is using #{charset}.

You are quite right here. Sorry, it was a quick patch to fix the annoying issue.

But I think that the right place to fix this issue is ActionMailer.

#14 Updated by Sergey Smirnov almost 7 years ago

I have similar problem with redmine 1.1.0
Notification subjects looks"
=?utf-8?Q?=5B=D0=A2=D0=B5=D1=81=D1=82=D0=BE=D0=B2=D1=8B=D0=B9_=D0=B4=D0=BB=D1=8F_=D0=BF=D1=80=D0=BE=D0=B2=D0=B5=D1=80=D0=BA=D0=B8_e=2Dmail_=2D_=D0=9C=D0=B8=D0=B3=D1=80=D0=B0=D1=86=D0=B8=D1=8F_=23=38=35=5D_=28=D0=9D=D0=BE=D0=B2=D1=8B=D0=B9=29_=D0=9F=D1=...
It's strange that subject doesn't end with "?=" but with "..."
I applied your patches but it didn't help.
I guess that long subject is cutted by redmine with "..."
Do anybody know this problem.
I user russian locale with utf-8 charset.
Thanks.

#15 Updated by Evgeniy Evteev over 6 years ago

patch not work in ver. 1.2.0
Help.

#16 Updated by Soonhyoung An over 6 years ago

i have same problem.
(redmine 1.2.1)

all mail title over 70(?) bytes was crashed

Help..

#17 Updated by Soonhyoung An over 6 years ago

sorry..
it was my mistake that report patch(mailer-long-subject-base64.patch )is not work with 1.2.1

it works very well..

(first patch only extends more char)
exact point of source code is before func create_mail
and as Stanislav German-Evtushenko commented

s.split.each { |part| @subject << "=?utf-8?B?#{part.strip}?=\r\n" }
should be change ->
s.split.each { |part| @subject << "=?#{charset}?B?#{part.strip}?=\r\n" }

#18 Updated by MIchael Ermolenko about 6 years ago

These patches solved our problem (Redmine v1.2.1).

Is it planned to include these patches into official code?

#19 Updated by Frédéric Géraud almost 6 years ago

I've got the same problem. Trouble is, it collides with my Outlook redirection rules which are based on email subject causing horrific mayhem in my inbox :)

Being a Redmine user, not a Redmine administrator, I cannot decide whereas to apply this patch or not. Anyway, I'll try & ask.

It would really be great it it was to be included in your next official release.
Thanks a lot.

#20 Updated by Toshi MARUYAMA over 3 years ago

  • Related to Defect #17752: mail subject come to unreadable code when it's too long added

#21 Updated by Toshi MARUYAMA over 3 years ago

  • Tracker changed from Patch to Defect
  • Subject changed from Unreadable quoted-printable utf-8 subject in some mail clients to Unreadable quoted-printable utf-8 long subject in some mail clients

#22 Updated by Toshi MARUYAMA over 3 years ago

  • Related to deleted (Defect #17752: mail subject come to unreadable code when it's too long)

#23 Updated by Toshi MARUYAMA over 3 years ago

  • Duplicated by Defect #17752: mail subject come to unreadable code when it's too long added

#24 Updated by lee min over 3 years ago

i have just upgrade my redmine server from 1.3.1 to 2.5.2 stable,but mail subject come to unreadable code when it's too long,according to the solvement above,I just do not know what to do since the mailing method has changed

#25 Updated by lee min over 3 years ago

#26 Updated by lee min over 3 years ago

the subject turn into base64code is caused by gem mail,below is my testing result
info about mail

@ [root@redmine test]# gem list mail * LOCAL GEMS **
actionmailer (4.1.5, 3.2.18)
mail (2.6.1, 2.5.4)@
my ruby test script:sendm.rb

require 'mail'
options = { :address => "mail._domain_.com",
:port => 25,
:domain => 'mail._domain_.com',
:user_name => '_<username>_',
:password => '_<password>_',
:authentication => 'login',
:openssl_verify_mode => 'none',}
Mail.defaults do
delivery_method :smtp, options
end
Mail.deliver do
to ''
from ''
subject '测试标题长度大于80个字节时的表现测试标题长度大于80个字节时的表现测试标题长度大>于80个字节时的表现测试标题长度大于80个字节时的表现测试标题长度大于80个字节时的表现'
body 'testing sendmail'
end

and then run the command: ruby sendm.rb
the subject of the mail has truned
=?UTF-8?Q? =E6=B5=8B=E8=AF=95=E6=A0=87=E9=A2=98=E9=95=BF=E5=BA=A6=E5=A4=A7=E4=BA=8E80=E4=B8=AA=E5=AD=97=E8=8A=82=E6=97=B6=E7=9A=84=E8=A1=A8=E7=8E=B0=E6=B5=8B=E8=AF=95=E6=A0=87=E9=A2=98=E9=95=BF=E5=BA=A6=E5=A4=A7=E4=BA=8E80=E4=B8=AA=E5=AD=97=E8=8A=82=E6=...

#27 Updated by Toshi MARUYAMA 11 months ago

  • Duplicated by Defect #24803: Incoming mailm subject are truncated added

#28 Updated by Toshi MARUYAMA 11 months ago

  • Related to Defect #16859: rdm-mailhandler: subject corruption added

#29 Updated by Toshi MARUYAMA 11 months ago

  • Duplicated by deleted (Defect #24803: Incoming mailm subject are truncated )

Also available in: Atom PDF