roundcube / roundcubemail

The Roundcube Webmail suite
https://roundcube.net
GNU General Public License v3.0
5.84k stars 1.63k forks source link

Wrong encoding of attacment's filenames, if they contains non-latin letters #4448

Closed rcubetrac closed 10 years ago

rcubetrac commented 10 years ago

Reported by mrlexy on 27 Jan 2014 11:55 UTC as Trac ticket #1489539

When attaching file with non-latin letters in filename to e-mail message, it's name may incorrect displaying in recepient's e-mail client, or attachment may be broken.

It was problem in program/steps/mail/sendmail.inc

Patch to solve this problem

--- program/steps/mail/sendmail.inc 2013-10-21 23:39:20.000000000 +0400
+++ temp/sendmail.inc   2014-01-27 15:27:18.000000000 +0400
@@ -642,7 +642,8 @@
         ($attachment[? false : true),
         ($ctype == 'message/rfc822' ? '8bit' : 'base64'),
         'attachment',
-        _, _, '',
+        $message_charset,
+   _, _,
         $CONFIG['mime_param_folding']('data']) ? 'quoted-printable' : NULL,
         $CONFIG['mime_param_folding'] == 2 ? 'quoted-printable' : NULL,
         '', RCMAIL_CHARSET

This cheapest bug present from 0.7.1 to 0.9.5 version.

Migrated-From: http://trac.roundcube.net/ticket/1489539

rcubetrac commented 10 years ago

Comment by @alecpl on 27 Jan 2014 13:10 UTC

What version of Mail_Mime package are you using? This fix is not needed. addAttachment() method documentation says the argument you've set is for attachment content not filename. For filename (headers) charset 13th argument should be used. Works for me.

Provide sent message source (with broken characters).

rcubetrac commented 10 years ago

Status changed by @alecpl on 27 Jan 2014 13:10 UTC

new => closed

rcubetrac commented 10 years ago

Milestone changed by @alecpl on 27 Jan 2014 13:10 UTC

=> 1.0-stable

rcubetrac commented 10 years ago

Comment by mrlexy on 27 Jan 2014 14:07 UTC

Version of Mail_Mime is 1.8.0

Sample source of message with broken characters (after first delimeter, Content-Type and Content-Disposition headers):

Received: from mxfront1o.mail.yandex.net ([mxfront1o.mail.yandex.net with LMTP id njDSiUeo
    for <mrlexy@yandex.ru>; Mon, 27 Jan 2014 14:49:45 +0400
Received: from mail.vo47.ru (mail.vo47.ru [193.106.108.90](127.0.0.1])
    by))
    by mxfront1o.mail.yandex.net (nwsmtp/Yandex) with ESMTPS id p9WROgObiP-njhWU4Au;
    Mon, 27 Jan 2014 14:49:45 +0400
    (using TLSv1 with cipher AES256-SHA (256/256 bits))
    (Client certificate not present)
X-Yandex-Front: mxfront1o.mail.yandex.net
X-Yandex-TimeMark: 1390819785
X-Yandex-Uniq: 1f615d6b-f692-49da-bc1c-d92a86d89f5b
X-Yandex-Spam: 1
Received: from www-data by mail.volkhov.info with local (Exim 4.76)
    (envelope-from <www-data@mail.volkhov.info>)
    id 1W7jkj-0000pP-91
    for mrlexy@yandex.ru; Mon, 27 Jan 2014 14:49:17 +0400
To: <mrlexy@yandex.ru>
Subject: =?UTF-8?Q?=D1=82=D0=B5=D1=81=D1=82=20JPEG?=
X-PHP-Originating-Script: 0:main.inc
MIME-Version: 1.0
Content-Type: multipart/mixed;
 boundary="=_00638ea65f04c322a9bd77a029833810"
Date: Mon, 27 Jan 2014 14:49:17 +0400
From: =?UTF-8?Q?=D0=90=D0=BB=D0=B5=D0=BA=D1=81=D0=B5=D0=B9_=D0=A1=D0=B1?=
 =?UTF-8?Q?=D0=B5=D1=80=D0=B5=D0=B3=D0=B0=D0=B5=D0=B2?= <mrlexy@vo47.ru>
Organization: =?UTF-8?Q?=D0=92=D0=BE=D0=BB=D1=85=D0=BE=D0=B2-=D0=9E=D0=BD?=
 =?UTF-8?Q?=D0=BB=D0=B0=D0=B9=D0=BD?=
Message-ID: <0e346c36332a90ab1aa1d6719278e9b7@vo47.ru>
X-Sender: mrlexy@vo47.ru
User-Agent: RoundCube Webmail/0.2.2
Sender: www-data <www-data@mail.volkhov.info>
Return-Path: www-data@mail.volkhov.info
X-Yandex-Forward: 871df053ee7fb3f13229466638e8d1e5
X-Yandex-Filter: 2360000000000687588

--=_00638ea65f04c322a9bd77a029833810
Content-Transfer-Encoding: 8bit
Content-Type: text/plain; charset=UTF-8;
 format=flowed

=== BODY SKIPPED ===

--=_00638ea65f04c322a9bd77a029833810
Content-Transfer-Encoding: base64
Content-Type: image/jpeg;
 name="=?US-ASCII?Q?=D0=92=D1=81=D1=91=D0=A0=D0=B0=D0=B1=D0=BE=D1=82=D0?=
 =?US-ASCII?Q?=B0=D0=B5=D1=82=2Ejpg?="
Content-Disposition: attachment;
 filename="=?US-ASCII?Q?=D0=92=D1=81=D1=91=D0=A0=D0=B0=D0=B1=D0=BE=D1=82?=
 =?US-ASCII?Q?=D0=B0=D0=B5=D1=82=2Ejpg?="

/9j/4AAQSkZJRgABAQEAYABgAAD/2wBDAAUDBAQEAwUEBAQFBQUGBwwIBwcHBw8LCwkMEQ8SEhEP
ERETFhwXExQaFRERGCEYGh0dHx8fExciJCIeJBweHx7/2wBDAQUFBQcGBw4ICA4eFBEUHh4eHh4e
Hh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh7/wAARCAPaBQADASIA
AhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQA
AAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3
ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWGh4iJipKTlJWWl5iZmqKjpKWm
p6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uHi4+Tl5ufo6erx8vP09fb3+Pn6/8QAHwEA
AwEBAQEBAQEBAQAAAAAAAAECAwQFBgcICQoL/8QAtREAAgECBAQDBAcFBAQAAQJ3AAECAxEEBSEx
BhJBUQdhcRMiMoEIFEKRobHBCSMzUvAVYnLRChYkNOEl8RcYGRomJygpKjU2Nzg5OkNERUZHSElK
U1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6goOEhYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3

=== ATTACHMENT CONTENT SKIPPED =====

8F+C7DwvPc3EF1LdzzDYHkQJsTrtwCc89T7Dgd+hyfU0ZPqaA1tY6jwiP3Mh/wCmn9BXSCud8Gc2
UhP/AD1P8hXRV5lb42epR+BBRRRWZoeG+ObnxNo9xa+INFhuNW0+3Ux6jo8EIaaSMn/XQdzIndM4
Zc4wRmrPgZfEsthPqfiiQQXN9IJYdNVRt0+LHyxlsZaTHLE8AnAAxz0I4ORRUFn/2Q==
--=_00638ea65f04c322a9bd77a029833810--
rcubetrac commented 10 years ago

Comment by mrlexy on 27 Jan 2014 14:12 UTC

Right headers (after patching) is

Content-Type: image/jpeg; charset=UTF-8;
 name="=?UTF-8?Q?=D0=92=D1=81=D1=91=D0=A0=D0=B0=D0=B1=D0=BE=D1=82=D0=B0?=
 =?UTF-8?Q?=D0=B5=D1=82=2Ejpg?="
Content-Disposition: attachment;
 filename="=?UTF-8?Q?=D0=92=D1=81=D1=91=D0=A0=D0=B0=D0=B1=D0=BE=D1=82=D0?=
 =?UTF-8?Q?=B0=D0=B5=D1=82=2Ejpg?="
rcubetrac commented 10 years ago

Comment by @alecpl on 27 Jan 2014 14:17 UTC

"?US-ASCII?Q?" is definitely wrong in this case. Did you modify Roundcube? Do you use any non-standard plugins? Could you check with recent Roundcube and recent Mail-Mime package?

rcubetrac commented 10 years ago

Comment by @alecpl on 27 Jan 2014 14:26 UTC

OK. Now I'm sure it's the problem with old Mail_mime. We require 1.8.1 since https://github.com/roundcube/roundcubemail/commit/53604a0550f9940584b7e4d4260b96714ae0edbf.

rcubetrac commented 10 years ago

Comment by mrlexy on 27 Jan 2014 14:35 UTC

No, I did not to modify Roundcube until that moment. All software installed from standard Ubuntu 12.04 LTS repository, wherein Roundcube version is 0.7.1. I just found problem in 0.7.1 version, then fix it and check latest version of Roundcube.

rcubetrac commented 10 years ago

Comment by mrlexy on 27 Jan 2014 14:44 UTC

I did upgrade Mail_Mime to 1.8.8 and now all works fine with Roundcube 0.7.1

Not be fully trusted to standard repositories ;-)

phenolog commented 7 years ago

@rcubetrac Your patch really works. Thank you.