Return-Path: X-Original-To: apmail-commons-issues-archive@minotaur.apache.org Delivered-To: apmail-commons-issues-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id C4F2410974 for ; Wed, 18 Sep 2013 07:56:08 +0000 (UTC) Received: (qmail 5267 invoked by uid 500); 18 Sep 2013 07:56:00 -0000 Delivered-To: apmail-commons-issues-archive@commons.apache.org Received: (qmail 5117 invoked by uid 500); 18 Sep 2013 07:55:54 -0000 Mailing-List: contact issues-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: issues@commons.apache.org Delivered-To: mailing list issues@commons.apache.org Received: (qmail 5077 invoked by uid 99); 18 Sep 2013 07:55:52 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 18 Sep 2013 07:55:52 +0000 Date: Wed, 18 Sep 2013 07:55:52 +0000 (UTC) From: "Olaf K. (JIRA)" To: issues@commons.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (EMAIL-130) Problem parsing EMail-Attachmentfilename (ISO-8859-15) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/EMAIL-130?page=3Dcom.atlassian.= jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=3D13770= 542#comment-13770542 ]=20 Olaf K. commented on EMAIL-130: ------------------------------- I try both system-properties but without success. I also set the system-pro= perty "mail.mime.decodetext.strict" to false. But this doesn't fix problem = as well. My patch works, so thx for investigating the problem. =20 > Problem parsing EMail-Attachmentfilename (ISO-8859-15) > ------------------------------------------------------ > > Key: EMAIL-130 > URL: https://issues.apache.org/jira/browse/EMAIL-130 > Project: Commons Email > Issue Type: Bug > Affects Versions: 1.3.1 > Environment: Thunderbird/17.0.5 > Reporter: Olaf K. > Priority: Critical > Attachments: Z=C3=A4hlerstandsmitteilung_06_13.pdf.eml, Z=C3=A4hl= erstandsmitteilung_06_13 pdf.msg > > > I use common-email-1.3.1 to parse emails from a imap-server. > After parsing an email with an pdf-attachment I received the following at= tachment-filename: ISO-8859-15''%5A%E4%68%6C%65%72%73%74%61%6E%64%73%6D%69%= 74%74 > But the filename should be =E2=80=9CZ=C3=A4hlerstandsmitteilung_06_13.pdf= =E2=80=9D. > I discovered the sourcecode and change the method MimeMessageParser.getDa= taSourceName() as follows: > {code} > =09protected String getDataSourceName(Part part, DataSource dataSource) t= hrows MessagingException, UnsupportedEncodingException { > =09=09String result =3D dataSource.getName(); > =09=09if (result =3D=3D null || result.length() =3D=3D 0) { > =09=09=09result =3D part.getFileName(); > =09=09} > =09=09if (result !=3D null && result.length() > 0) { > =09=09=09result =3D MimeUtility.decodeText(result); > =09=09} else { > =09=09=09result =3D null; > =09=09} > // NEW-Start > =09=09// result could be =3D ISO-8859-15''%5A%E4%68%6C%65%72%73%74%61%6E%= 64%73%6D%69%74%74 > =09=09if (result.indexOf("%") !=3D -1) { > =09=09=09String rawContentType =3D part.getContentType(); > =09=09=09// extract the name from contenttype: application/pdf;\n\rname= =3D"=3D?ISO-8859-15?Q?Z=3DE4hlerstandsmitteilung=3D5F06=3D5F13=3D2Epdf?=3D" > =09=09=09int nameIndex =3D rawContentType.indexOf("name=3D\""); > =09=09=09if (nameIndex !=3D -1) { > =09=09=09=09rawContentType =3D rawContentType.substring(nameIndex); > =09=09=09=09rawContentType =3D rawContentType.substring(rawContentType.in= dexOf('"') + 1, rawContentType.lastIndexOf('"')); > =09=09=09=09// ISO-Decoding > =09=09=09=09if (rawContentType.startsWith("=3D?") || rawContentType.endsW= ith("?=3D")) { > =09=09=09=09=09result =3D MimeUtility.decodeText(rawContentType); > =09=09=09=09} > =09=09=09} > =09=09} > // NEW-END > =09=09return result; > =09} > {code} > Tested with ISO-8859-15 encoded emails. > You could reproduce this behavior with the following steps. > - Create an PDF with the filename "Z=C3=A4hlerstandsmitteilung_06_13.pdf" > - Create an EMail with Tunderbird. > - Set EMail-Format RawText and encoding to ISO-8859-15 > I attached such an email to this issue (msg-Outlook and eml-Thunderbird). > part.getFilename return: ISO-8859-15''%5A%E4%68%6C%65%72%73%74%61%6E%64%7= 3%6D%69%74%74 > It should: =3D?iso-8859-1?Q?Z=3DE4hlerstandsmitteilung=3D5F06=3D5F13.pdf?= =3D > With this kind of filename MimeUtility.decodeText(result); fix the encodi= ng. > =20 -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrato= rs For more information on JIRA, see: http://www.atlassian.com/software/jira