[ 
https://issues.apache.org/jira/browse/EMAIL-199?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17426047#comment-17426047
 ] 

Michael Osipov commented on EMAIL-199:
--------------------------------------

Finally the message is complete!

WTF, who produced this crap? From a library point of view this body is empty. 
Let's dissect:

The important header is {{Content-Type: multipart/alternative; 
boundary="Apple-Mail=_FF990D9B-8883-4281-92BC-11706B5C3A3D"}} and body starts 
after {{Resent-Message-Id: <[email protected]>}}. 
After that for the first part we need to parse down to the boundary 
{{\-\-Apple-Mail=_FF990D9B-8883-4281-92BC-11706B5C3A3D\-}}. It does not appear 
at all. We only have 
{{\-\-Apple-Mail=_FF990D9B-8883-4281-92BC-11706B5C3A3D\-\-}}.

Since there are no parts this entire part is handled as preamble and skipped 
altogether:
{noformat}
Content-Transfer-Encoding: 7bit
Content-Type: text/plain; charset=us-ascii

Content-Type: multipart/mixed; 
boundary="Apple-Mail=_E60996BB-B6EA-47B8-ACEC-73CC338813B5"


--Apple-Mail=_E60996BB-B6EA-47B8-ACEC-73CC338813B5
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html; charset=us-ascii

Content-Disposition: attachment; filename=3529636.xlsx
Content-Type: 
application/vnd.openxmlformats-officedocument.spreadsheetml.sheet; 
x-unix-mode=0644; name="3529636.xlsx"
Content-Transfer-Encoding: quoted-printable

Content-Transfer-Encoding: 7bit
Content-Type: text/html; charset=us-ascii

Content-Disposition: inline; filename=3755032.pdf
Content-Type: application/pdf; x-mac-hide-extension=yes; x-unix-mode=0644; 
name="3755032.pdf"
Content-Transfer-Encoding: base64

-Apple-Mail=_E60996BB-B6EA-47B8-ACEC-73CC338813B5
Content-Transfer-Encoding: 7bit
Content-Type: text/html; charset=us-ascii

Content-Disposition: attachment; filename=909.zip
Content-Type: application/zip; x-unix-mode=0644; name="909.zip"
Content-Transfer-Encoding: base64

Content-Transfer-Encoding: 7bit
Content-Type: text/html; charset=us-ascii
{noformat}

Let's assume the above would be the body, it is broken as well. There are 
missing boundaries between parts, contradicting {{Content-Transfer-Encodings}}, 
{{-Apple-Mail=_E60996BB-B6EA-47B8-ACEC-73CC338813B5}} is missing a leading 
hyphen. {{\-\-Apple-Mail=_E60996BB-B6EA-47B8-ACEC-73CC338813B5\-\-}} is missing 
completely.

You might be better off with Apache James MIME4J low level to get the preamble 
and process yourself.

> MimeMessageParser.parse() throws "Missing start boundary" exception
> -------------------------------------------------------------------
>
>                 Key: EMAIL-199
>                 URL: https://issues.apache.org/jira/browse/EMAIL-199
>             Project: Commons Email
>          Issue Type: Bug
>    Affects Versions: 1.5
>            Reporter: Theodosios Andreou
>            Priority: Major
>         Attachments: Mime code, msg-20211005205902-7d3d845c.eml.headers
>
>
> h4. Description
> I have a MIME header file generated by `ripmime` that should reflect an 
> attachment within its boundaries (see attachment).
> The code used to replicate the error is also attached.
>  
>  
> *Expected behavio**r*: The parser should be able to complete and return back 
> ` 3529636.pdf` when we call `getAttachmentList()` on it.
>  
> *Workaround*: I haven't found one. It seems that the Mime header is corrupted 
> but `ripmime` reports it as valid. 
>  
> *Optimal solution*: Be able to process such Mime headers. 



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to