From issues-return-68700-archive-asf-public=cust-asf.ponee.io@commons.apache.org Mon Jul 16 22:18:04 2018 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id E1BA7180657 for ; Mon, 16 Jul 2018 22:18:03 +0200 (CEST) Received: (qmail 22958 invoked by uid 500); 16 Jul 2018 20:18:02 -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 22945 invoked by uid 99); 16 Jul 2018 20:18:02 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 16 Jul 2018 20:18:02 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd2-us-west.apache.org (ASF Mail Server at spamd2-us-west.apache.org) with ESMTP id 66AD01A0113 for ; Mon, 16 Jul 2018 20:18:02 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -110.301 X-Spam-Level: X-Spam-Status: No, score=-110.301 tagged_above=-999 required=6.31 tests=[ENV_AND_HDR_SPF_MATCH=-0.5, RCVD_IN_DNSWL_MED=-2.3, SPF_PASS=-0.001, USER_IN_DEF_SPF_WL=-7.5, USER_IN_WHITELIST=-100] autolearn=disabled Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id 23wd2al0rNGr for ; Mon, 16 Jul 2018 20:18:01 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTP id 0BE075F117 for ; Mon, 16 Jul 2018 20:18:01 +0000 (UTC) Received: from jira-lw-us.apache.org (unknown [207.244.88.139]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id 44DF0E00D3 for ; Mon, 16 Jul 2018 20:18:00 +0000 (UTC) Received: from jira-lw-us.apache.org (localhost [127.0.0.1]) by jira-lw-us.apache.org (ASF Mail Server at jira-lw-us.apache.org) with ESMTP id 0543421EE2 for ; Mon, 16 Jul 2018 20:18:00 +0000 (UTC) Date: Mon, 16 Jul 2018 20:18:00 +0000 (UTC) From: "sid (JIRA)" To: issues@commons.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Created] (EMAIL-180) Unable to read filename with 28+ characters MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 sid created EMAIL-180: -------------------------- Summary: Unable to read filename with 28+ characters =20 Key: EMAIL-180 URL: https://issues.apache.org/jira/browse/EMAIL-180 Project: Commons Email Issue Type: Bug Reporter: sid=20 Hello, I am using apache.common.email version 1.5 and trying to parse outlook emai= l, I have noticed bodyPart .getFileName() returns value *null* ( where bodyPa= rt =3D (Multipart) mimeMessage.getContent().getBodyPart()), with headers su= ch as below(generated within outlook email) for an example - --_004_BN6PR05MB28973EFBD6850890BFB0E931E25E0BN6PR05MB2897namp_ Content-Type: application/pdf; {color:#FF0000}name=3D"ABCDEFG=C2=A0test case without contract id #1.pdf"{c= olor} Content-Description: ABCDEFG=C2=A0test case without contract id #1.pdf Content-Disposition: attachment; filename=3D"ABCDEFG=C2=A0test case without contract id #1.pdf"; size=3D4844= 17; creation-date=3D"Sun, 15 Jul 2018 15:12:47 GMT"; modification-date=3D"Sun, 15 Jul 2018 15:13:15 GMT" Content-Transfer-Encoding: base64 my primary observation is - due to character limitation according to RFC, t= he headers gets broken and gets displaced on next separate line - which par= ser is unable to parse. However, for now - I am using this custom method to handle such issues. public static String parseDescriptionFileHeader(Enumeration headerEnumerati= on) { String fileName =3D null; try { while (headerEnumeration.hasMoreElements()) { Header header =3D (Header) headerEnumeration.nextElement(); String name =3D header.getName(); if(name.contains("name=3D")) { Pattern p =3D Pattern.compile("\"([^\"]*)\""); Matcher m =3D p.matcher(name); while (m.find()) { fileName =3D m.group(1); return fileName; } } } =20 } catch (Exception e) { system.out.println("Unable to retrieve attachement header"); } return fileName; } Let me know, if there is any standard solution to the above issue, Thank yo= u. Regards -- This message was sent by Atlassian JIRA (v7.6.3#76005)