commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sumit Agrawal (JIRA)" <j...@apache.org>
Subject [jira] [Created] (EMAIL-173) In case of multipart/alternative consider alternatives if one of them is corrupted
Date Tue, 23 May 2017 06:09:04 GMT
Sumit Agrawal created EMAIL-173:
-----------------------------------

             Summary: In case of multipart/alternative consider alternatives if one of them
is corrupted
                 Key: EMAIL-173
                 URL: https://issues.apache.org/jira/browse/EMAIL-173
             Project: Commons Email
          Issue Type: Bug
            Reporter: Sumit Agrawal


In case of multipart/alternative, it can happen that some of the alternatives are corrupted.

In such cases rather than throwing an exception for malformed part, it makes sense to use
one of the well-formed alternatives. 

The code in question is here:
https://commons.apache.org/proper/commons-email/apidocs/src-html/org/apache/commons/mail/util/MimeMessageParser.html

line 192.

The patch should look something like this
{code:java}
                if (isMimeType(part, "multipart/alternative"))
                {
                    this.isMultiPart = true;
                    final Multipart mp = (Multipart) part.getContent();
                    final int count = mp.getCount();

                    // iterate over all MimeBodyPart

                    int failureCount = 0;
                    for (int i = 0; i < count; i++)
                    {
                        try {
                             parse(mp, (MimeBodyPart) mp.getBodyPart(i));
                           } catch (Exception e) {
                              // LOG this error
                              failureCount++;
                           }
                    }
                    if (failureCount == count) {
                    // if all of them failed.
                    throw new IOException(); // with reason
                    }
                }
               if (isMimeType(part, "multipart/*"))
               {
                    // normal flow
                }
{code}




--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

Mime
View raw message