Apache OpenOffice (AOO) Bugzilla – Full Text Issue Listing |
Summary: | XMailMessage attachment unusable if file name (ReadableName) contains non-ASCII characters | ||
---|---|---|---|
Product: | App Dev | Reporter: | DonJaime <donjaime> |
Component: | api | Assignee: | Ariel Constenla-Haile <arielch> |
Status: | CLOSED FIXED | QA Contact: | |
Severity: | Normal | ||
Priority: | P5 (lowest) | CC: | arielch, issues |
Version: | 3.3.0 or older (OOo) | ||
Target Milestone: | --- | ||
Hardware: | All | ||
OS: | All | ||
Issue Type: | DEFECT | Latest Confirmation in: | --- |
Developer Difficulty: | --- | ||
Attachments: |
According to http://docs.python.org/library/email.message.html?highlight=add_header#email.message.Message.add_header For each item in the keyword argument dictionary _params, the key is taken as the parameter name, with underscores converted to dashes (since dashes are illegal in Python identifiers). Normally, the parameter will be added as key="value" unless the value is None, in which case only the key will be added. If the value contains non-ASCII characters, it must be specified as a three tuple in the format (CHARSET, LANGUAGE, VALUE), where CHARSET is a string naming the charset to be used to encode the value, LANGUAGE can usually be set to None or the empty string (see RFC 2231 for other possibilities), and VALUE is the string value containing non-ASCII code points. An example with non-ASCII characters: msg.add_header('Content-Disposition', 'attachment', filename=('iso-8859-1', '', 'Fußballer.ppt')) Which produces Content-Disposition: attachment; filename*="iso-8859-1''Fu%DFballer.ppt" Created attachment 77136 [details]
mailmerge.py with some fixes
@DonJaime: please replace ${ROOT_INST_DIR}/openoffice.org/basis3.${MINOR}/program/mailmerge.py with the one attached in this bug (first back-up the original one). The fix to this issue is encoding the ReadableName to utf-8: msgattachment.add_header(\ 'Content-Disposition', \ 'attachment', \ filename=('utf-8','',attachment.ReadableName.encode('utf-8'))) Replaced as instructed. I had to edit line 46 to dbg = False because the ascii codec was choking on line 128, and when that was fixed I got: An exception occurred Type: com.sun.star.uno.RuntimeException Message: <type 'exceptions.RuntimeError'>: No SSL support included in this Python, traceback follows C:\Program Files\OpenOffice.org 3\Basis\program\python-core-2.6.1\lib\smtplib.py:615 in function starttls() [raise RuntimeError("No SSL support included in this Python")] C:\Program Files\OpenOffice.org 3\Basis\program\mailmerge.py:88 in function connect() [self.server.starttls()] . So I used ConnectionType Insecure and then it worked. Fixed in revision 1232130 (In reply to comment #4) > Replaced as instructed. I had to edit line 46 to dbg = False because the ascii > codec was choking on line 128, and when that was fixed I got: > > An exception occurred > Type: com.sun.star.uno.RuntimeException > Message: <type 'exceptions.RuntimeError'>: No SSL support included in this > Python, traceback follows > C:\Program Files\OpenOffice.org > 3\Basis\program\python-core-2.6.1\lib\smtplib.py:615 in function starttls() > [raise RuntimeError("No SSL support included in this Python")] > C:\Program Files\OpenOffice.org 3\Basis\program\mailmerge.py:88 in function > connect() [self.server.starttls()] > . > > So I used ConnectionType Insecure and then it worked. yes, this was bug 118787 that made you use insecure connection when specifying "SSL". It compared"Ssl" != "SSL" in a case sensitive way; as these string are not equal, it used an insecure connection. This seem to have worked for you (your smtp server seems to use insecure connection), but didn't work with Gmail's smtp server for example. Revision 118791 Encode ReadableName in UTF-8 only when necessary Created attachment 77165 [details]
Localized mail attachments readable name UTF-8 encoded - Mutt client - Linux
Created attachment 77166 [details]
Localized mail attachments readable name UTF-8 encoded - Thunderbird client - WinXP
(In reply to comment #7) > Revision 118791 > Encode ReadableName in UTF-8 only when necessary I meant revision 1235677 |
Created attachment 77134 [details] Test file sends two messages, one with attachment "Confirmation", one with attachment "Bestätigung" If XMailServer is used to send an XMailMessage with an attachment whose ReadableName contains non-ASCII character, the attachment header is garbled and the attachment cannot be extracted. For example: if the attachment name is "Bestätigung", the Content-Disposition header is rendered as: Content-Disposition: =?utf-8?q?attachment=3B_filename=3D=22Best=C3=A4tigung?= =?utf-8?q?=22?= while with file name "Confirmation", the header is: Content-Disposition: attachment; filename="Confirmation" Presumably the problem is something simple like "encode(foo & bar)" instead of "foo & encode(bar)"