Bug 55411 - Mailmerge: Attachment with foreign chars in filename produces incorrect MIME headers
Summary: Mailmerge: Attachment with foreign chars in filename produces incorrect MIME ...
Status: VERIFIED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
3.6.1.2 release
Hardware: x86-64 (AMD64) macOS (All)
: medium normal
Assignee: Caolán McNamara
URL:
Whiteboard: target:4.2.0 target:4.1.0.2 target:4.0.5
Keywords:
Depends on:
Blocks:
 
Reported: 2012-09-28 11:22 UTC by Rolf Eder
Modified: 2013-06-20 15:58 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Rolf Eder 2012-09-28 11:22:20 UTC
If you do an e-mail merge with an attachment and the filename has foreign characters (e. g. German umlauts) the resulting mail has incorrect MIME headers (first part of "Content-Disposition" I suppose).

Some mail programs will ignore this and show the attachment anyway (Mac OS mail.app which renames the attachment to a default name). Others fail to show the attachment completely (tested with different Webmailers, MS Outlook, ...).

Some examples:

LibO 3.6 (note the unnecessary UTF-encoded "attachment;")

--===============1083777418==
Content-Type: application/pdf
MIME-Version: 1.0
Content-Transfer-Encoding: base64
Content-Disposition: =?utf-8?q?attachment=3B_filename=3D=22Fru=CC=88hlingsm?=
	=?utf-8?q?arkt_2013_Bewerbungsbogen=2Epdf=22?=


A "correct" (readable by all tested mail apps) version produced by Thunderbird


--------------070803060102000807020303
Content-Type: application/pdf;
 name="erw poliz =?UTF-8?B?RnXMiGhydW5nc3pldWduaXMucGRm?="
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
 filename*0*=UTF-8''%65%72%77%20%70%6F%6C%69%7A%20%46%75%CC%88%68%72%75%6E;
 filename*1*=%67%73%7A%65%75%67%6E%69%73%2E%70%64%66

Or something like this (Kerio Connect WebMail with different char set):

-------------bde77112a49a8fcc00e1f31ee505516f
Content-Type: application/pdf
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
	filename="=?iso-8859-1?Q?=DCmlaute=2Epdf?="
Comment 1 Alex Thurgood 2012-09-28 14:22:09 UTC
Check out bug 38713 and see whether it is the same problem. It might be that the fix for that bug was incomplete, or has accidentally been reverted.


Alex
Comment 2 Alex Thurgood 2012-09-28 14:24:17 UTC
Adding Caolan to CC.

Does this ring a bell ?


Alex.
Comment 3 Rolf Eder 2012-09-28 14:43:54 UTC
Alex,

https://bugs.freedesktop.org/show_bug.cgi?id=38713 was something about multiple recipients.

No problem here. I can mailmerge to hundreds of recipients with no error. The attachment is included in the "source" of the mail body but is visible only to those with a MUA not taking RFC 2183 too literal.

If it not the disposition-type please feel free to ask for more or complete samples.

TIA
-- 
Rolf
Comment 4 QA Administrators 2013-05-29 23:05:02 UTC
Dear Bug Submitter,

This bug has been in NEEDINFO status with no change for at least 6 months. Please provide the requested information as soon as possible and mark the bug as UNCONFIRMED. Due to regular bug tracker maintenance, if the bug is still in NEEDINFO status with no change in 30 days the QA team will close the bug as INVALID due to lack of needed information.

For more information about our NEEDINFO policy please read the wiki located here: 
https://wiki.documentfoundation.org/QA/FDO/NEEDINFO

If you have already provided the requested information, please mark the bug as UNCONFIRMED so that the QA team knows that the bug is ready to be confirmed.


Thank you for helping us make LibreOffice even better for everyone!


Warm Regards,
QA Team
Comment 5 Rolf Eder 2013-06-06 07:26:36 UTC
I checked again with 4.0.3.3 and Mac OS X 10.8.4:

Mailmerge will not send a PDF attachment with foreign characters (e. g. German Umlaut) in filename - now it crashes with the following python error


<class 'TypeError'>: quote() doesn't support 'encoding' for bytes, traceback follows
  /Applications/LibreOffice.app/Contents/program/LibreOfficePython.framework/Versions/Current/lib/python3.3/urllib/parse.py:695 in function quote() [raise TypeError("quote() doesn't support 'encoding' for bytes")]
  /Applications/LibreOffice.app/Contents/program/LibreOfficePython.framework/Versions/Current/lib/python3.3/email/utils.py:265 in function encode_rfc2231() [s = urllib.parse.quote(s, safe='', encoding=charset or 'ascii')]
  /Applications/LibreOffice.app/Contents/program/LibreOfficePython.framework/Versions/Current/lib/python3.3/email/message.py:56 in function _formatparam() [value = utils.encode_rfc2231(value[2], value[0], value[1])]
  /Applications/LibreOffice.app/Contents/program/LibreOfficePython.framework/Versions/Current/lib/python3.3/email/message.py:490 in function add_header() [parts.append(_formatparam(k.replace('_', '-'), v))]
  /Applications/LibreOffice.app/Contents/program/mailmerge.py:246 in function sendMailMessage() [filename=fname)]
Comment 6 Alex Thurgood 2013-06-14 03:16:27 UTC
Confirming. I can reproduce the problem on :



The error message :

<class 'TypeError'>: quote() doesn't support 'encoding' for bytes, traceback follows
  /Applications/LibreOfficeDev.app/Contents/program/LibreOfficePython.framework/Versions/Current/lib/python3.3/urllib/parse.py:695 in function quote() [raise TypeError("quote() doesn't support 'encoding' for bytes")]
  /Applications/LibreOfficeDev.app/Contents/program/LibreOfficePython.framework/Versions/Current/lib/python3.3/email/utils.py:265 in function encode_rfc2231() [s = urllib.parse.quote(s, safe='', encoding=charset or 'ascii')]
  /Applications/LibreOfficeDev.app/Contents/program/LibreOfficePython.framework/Versions/Current/lib/python3.3/email/message.py:56 in function _formatparam() [value = utils.encode_rfc2231(value[2], value[0], value[1])]
  /Applications/LibreOfficeDev.app/Contents/program/LibreOfficePython.framework/Versions/Current/lib/python3.3/email/message.py:490 in function add_header() [parts.append(_formatparam(k.replace('_', '-'), v))]
  /Applications/LibreOfficeDev.app/Contents/program/mailmerge.py:246 in function sendMailMessage() [filename=fname)]

Alex
Comment 7 Alex Thurgood 2013-06-14 03:17:41 UTC
@Caolan : any insight ?


Alex
Comment 8 Alex Thurgood 2013-06-14 03:22:33 UTC
Forgot to mention that this is also confirmed in my master build :

Version: 4.2.0.0.alpha0+
Build ID: c2530b02311c46529eed53ee688bf6c83ce4b86



Alex
Comment 9 Alex Thurgood 2013-06-14 03:26:27 UTC
However, the app as a whole does not crash, only the mailmerge functionality fails with the python error message you indicated. I can close the mailmerge window and continue working with LO, but yes this does mean that that particular bit doesn't work.

Also, there appears to be a workaround in that you can rename the pdf file that LO creates in the "File Name" dialog to not contain any extended characters.


Alex
Comment 10 Alex Thurgood 2013-06-14 03:46:55 UTC
Hmmm, I appear to have discovered another problem - the document that got sent as a PDF was completely empty, just a blank sheet, whereas the ODT document used as the basis for the mailmerge contained text, and at least the salutations. This might already be registered as a bug in the system, will check it out.


Alex
Comment 11 Commit Notification 2013-06-17 13:01:00 UTC
Caolan McNamara committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=06f22f5ae0eafe094b280f03c770eebdbb33d403

Resolves: fdo#55411 python 2 vs 3 str/bytes encoding issues



The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds
Affected users are encouraged to test the fix and report feedback.
Comment 12 Caolán McNamara 2013-06-18 19:14:46 UTC
should be good in master, proposing for 4-1
Comment 13 Commit Notification 2013-06-18 20:59:34 UTC
Caolan McNamara committed a patch related to this issue.
It has been pushed to "libreoffice-4-1":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=540a681e4d6ed0d88a542c843dbf534fb661abf8&h=libreoffice-4-1

Resolves: fdo#55411 python 2 vs 3 str/bytes encoding issues


It will be available in LibreOffice 4.1.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds
Affected users are encouraged to test the fix and report feedback.
Comment 14 Commit Notification 2013-06-18 20:59:53 UTC
Caolan McNamara committed a patch related to this issue.
It has been pushed to "libreoffice-4-0":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=350994ffdc51787ecd51a8b7ce4e504c2432dd9d&h=libreoffice-4-0

Resolves: fdo#55411 python 2 vs 3 str/bytes encoding issues


It will be available in LibreOffice 4.0.5.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds
Affected users are encouraged to test the fix and report feedback.
Comment 15 Alex Thurgood 2013-06-20 15:58:48 UTC
works on osx with my latest master build too