You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Siegfried Goeschl (JIRA)" <ji...@apache.org> on 2017/07/17 21:12:00 UTC

[jira] [Resolved] (EMAIL-173) In case of multipart/alternative consider alternatives if one of them is corrupted

     [ https://issues.apache.org/jira/browse/EMAIL-173?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Siegfried Goeschl resolved EMAIL-173.
-------------------------------------
    Resolution: Won't Fix
      Assignee: Siegfried Goeschl

I'm personally not happy with the suggestion

* I don't like silently dropping some parts of the email
* Please note that commons-email is not using any logging
* You can overwrite the protected method to add your own fault-tolerant parsing logic

> 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
>            Assignee: Siegfried Goeschl
>
> 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.4.14#64029)