[
https://issues.apache.org/jira/browse/EMAIL-180?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16545741#comment-16545741
]
Sebb commented on EMAIL-180:
----------------------------
If the headers really are as per the description - no spaces on folded lines -
then it is not surprising that there are issues with the parsing.
Please attach a sample outlook source file with a minimal Java program that
shows the problem.
> Unable to read filename with 28+ characters
> ---------------------------------------------
>
> Key: EMAIL-180
> URL: https://issues.apache.org/jira/browse/EMAIL-180
> Project: Commons Email
> Issue Type: Bug
> Reporter: sid
> Priority: Major
>
> Hello,
> I am using apache.common.email version 1.5 and trying to parse outlook email,
> I have noticed bodyPart .getFileName() returns value *null* ( where bodyPart
> = (Multipart) mimeMessage.getContent().getBodyPart()), with headers such as
> below(generated within outlook email) for an example -
> --_004_BN6PR05MB28973EFBD6850890BFB0E931E25E0BN6PR05MB2897namp_
> Content-Type: application/pdf;
> {color:#FF0000}name="ABCDEFG test case without contract id #1.pdf"{color}
> Content-Description: ABCDEFG test case without contract id #1.pdf
> Content-Disposition: attachment;
> filename="ABCDEFG test case without contract id #1.pdf"; size=484417;
> creation-date="Sun, 15 Jul 2018 15:12:47 GMT";
> modification-date="Sun, 15 Jul 2018 15:13:15 GMT"
> Content-Transfer-Encoding: base64
> my primary observation is - due to character limitation according to RFC, the
> headers gets broken and gets displaced on next separate line - which parser
> is unable to parse.
> However, for now - I am using this custom method to handle such issues.
> public static String parseDescriptionFileHeader(Enumeration
> headerEnumeration) {
> String fileName = null;
> try {
> while (headerEnumeration.hasMoreElements()) {
> Header header = (Header) headerEnumeration.nextElement();
> String name = header.getName();
> if(name.contains("name="))
> {
> Pattern p = Pattern.compile("\"([^\"]*)\"");
> Matcher m = p.matcher(name);
> while (m.find()) {
> fileName = m.group(1);
> return fileName;
> }
> }
> }
>
> } 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 you.
> Regards
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)