roundcube / roundcubemail

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

Attachments encoding problem #3308

Closed rcubetrac closed 13 years ago

rcubetrac commented 13 years ago

Reported by nexus on 1 Mar 2011 00:40 UTC as Trac ticket #1487808

I have the latest (0.51) version of Roundcube and use RFC 2047/2231 attachment name settings. Also I use UTF-8 encoding as default.

Attachment file names encode fine in general but there are two exceptions:

  1. File name with underscore encodes incorrectly after sending but shows normally in upload frame. The same files show correctly in Roundcube if I send them from other client. So mail server works fine.
  2. ANSI encoded text files shows incorrectly after message body. And I don't even know how to disable function that shows them.

Thanks

Keywords: Attachments encoding Migrated-From: http://trac.roundcube.net/ticket/1487808

rcubetrac commented 13 years ago

Comment by @alecpl on 1 Mar 2011 07:18 UTC

Please, attach message source.

rcubetrac commented 13 years ago

Milestone changed by @alecpl on 1 Mar 2011 07:18 UTC

later => 0.6-beta

rcubetrac commented 13 years ago

Comment by nexus on 1 Mar 2011 10:47 UTC

File "test.eml" has been attached.

rcubetrac commented 13 years ago

Comment by @alecpl on 1 Mar 2011 10:59 UTC

For some reason the attachment name in Content-Type header is not encoded at all. Are you using "dependent" Roundcube package? What version of Mail_Mime are you using?

rcubetrac commented 13 years ago

Comment by nexus on 1 Mar 2011 11:08 UTC

I'm sorry. How to know what version of Mail_Mime I'm using? I haven't set anything Mail_Mime related settings.

rcubetrac commented 13 years ago

Comment by nexus on 1 Mar 2011 11:17 UTC

I have found file /program/lib/Mail/mime.php It seems that version is "CVS: $Id: mime.php 4295 2010-12-01 10:49:20Z alec".

rcubetrac commented 13 years ago

Comment by @alecpl on 1 Mar 2011 11:32 UTC

The file looks ok. It works for me. So, we'll need more info about your environment, PHP/OS version, etc.

rcubetrac commented 13 years ago

Comment by nexus on 1 Mar 2011 11:40 UTC

Windows 7, IIS, PHP 5.3.3. Anything else?

rcubetrac commented 13 years ago

Comment by @alecpl on 1 Mar 2011 11:55 UTC

Content-Transfer-Encoding: base64
Content-Type: text/plain;
 name="_.txt"
Content-Disposition: attachment;
 filename*0*=UTF-8''%D0%9F%D0%BE%D0%B7%D0%B4%D1%80%D0%B0%D0%B2%D0%B8%D1%82;
 filename*1*=%D0%B5%D0%BB%D1%8C%D0%BD%D1%8B%D0%B5_%D0%BE%D1%82%D0%BA%EF%BF;
 filename*2*=%BD%EF%BF%BD%D1%8B%D1%82%D0%BA%D0%B8.txt

I see two issues here. 1. Why Content-Type contains non-encoded filename? 2. Why filename contains garbage characters %EF%BF%BD%EF? I have no idea.

rcubetrac commented 13 years ago

Comment by nexus on 1 Mar 2011 12:12 UTC

Where filename should be encoded in program code? Shall I provide debug information at this line?

Can you repeat this test on your machine with similar circumstances?

rcubetrac commented 13 years ago

Comment by @alecpl on 1 Mar 2011 12:31 UTC

No, I'm unable to reproduce. I'm using linux, PHP 5.3.3/5.3.5. You could start debugging from program/lib/Mail/mimePart.php file and _buildHeaderParam() function.

rcubetrac commented 13 years ago

Comment by nexus on 1 Mar 2011 14:19 UTC

Whole Mail_mimePart() function sets correct Content-Type headers.

In my case:

headers[Content-Type] = application/x-empty; name="=?UTF-8?Q?=D0=9F=D0=BE=D0=B7=D0=B4=D1=80=D0=B0=D0=B2=D0=B8=D1=82?= =?UTF-8?Q?=D0=B5=D0=BB=D1=8C=D0=BD=D1=8B=D0=B5=5F=D0=BE=D1=82=D0=BA=D1?= =?UTF-8?Q?=80=D1=8B=D1=82=D0=BA=D0=B8=2Etxt?="

But for unknown reasons Content-Type headers rewrites by some another function higher in call stack.

Filename garbage characters returns _buildHeaderParam() function.

rcubetrac commented 13 years ago

Comment by nexus on 1 Mar 2011 21:28 UTC

I'm sorry. It was server-side issue. Mail server forcibly decoded filenames in headers. And did it incorrecly. So disabling this function solved the problem.

Alec I have some considerations of your second question about "filename" param: in my mail messages "name" and "filename" params are equal, so maybe "filename" is additional field for better compatibility with other servers/clients. If so it not a bug too. Nevertheless it certainly isn't a garbage characters)

Alec thank you for you help.

I know that ticket should be closed but I just can't realise one thing: now sending messages with attachment "_.txt" to my server, Gmail, Yandex works fine but Mail.ru have the same problem at the same characters. I mean my server fails to decode UTF8 encoded filename properly and Mail.ru too. So I can't realise where is mistake in decoding operations? (It's exists right?)

rcubetrac commented 13 years ago

Comment by @alecpl on 2 Mar 2011 07:08 UTC

Show header and I'll tell you if they are properly encoded or not.

rcubetrac commented 13 years ago

Status changed by @alecpl on 2 Mar 2011 07:08 UTC

new => closed

rcubetrac commented 13 years ago

Comment by nexus on 2 Mar 2011 15:07 UTC

There is a header:

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

Test --=_27c5b39c51662f7ff09a3e65577ae4d9 Content-Transfer-Encoding: base64 Content-Type: application/x-empty; name="=?UTF-8?Q?=D0=9F=D0=BE=D0=B7=D0=B4=D1=80=D0=B0=D0=B2=D0=B8=D1=82?= =?UTF-8?Q?=D0=B5=D0=BB=D1=8C=D0=BD=D1=8B=D0=B5=5F=D0=BE=D1=82=D0=BA=D1?= =?UTF-8?Q?=80=D1=8B=D1=82=D0=BA=D0=B8=2Etxt?=" Content-Disposition: attachment; filename0=UTF-8''%D0%9F%D0%BE%D0%B7%D0%B4%D1%80%D0%B0%D0%B2%D0%B8%D1%82; filename1=%D0%B5%D0%BB%D1%8C%D0%BD%D1%8B%D0%B5_%D0%BE%D1%82%D0%BA%D1%80; filename2=%D1%8B%D1%82%D0%BA%D0%B8.txt

--=_27c5b39c51662f7ff09a3e65577ae4d9--