Skip to content

Parsing child parts of multipart fails when boundary ends with space. #266

Description

@ben221199

For reference, I use the same m4007 mail as found in this project.

The first part is a message/rfc822 part. This library doesn't parse the part, as issued in #265, so I use the following code to force subparsing:

$rfc822part = MIMEMessage::from($message->getContent(),true);

Now that I can access the information of this part, I check both $rfc822part->isMultiPart() and $rfc822part->getChildParts(). The former returns true. However, the latter returns [], so no child parts.

I investigated this problem, and I found out it had something to do with the boundary. When I used the following code to change the Content-Type header and forced reparsing, the child parts where also found:

$rfc822part->setRawHeader(HeaderConsts::CONTENT_TYPE,'multipart/digest; boundary="foo "');
$rfc822part = MIMEMessage::from($rfc822part->getStream()->getContents(),true);

And because the previous code changes the \n in the header to \r\n, the following code where this doesn't happen also works:

$rfc822part = MIMEMessage::from(str_replace('boundary="foo"','boundary="foo "',$rfc822part->getStream()->getContents()),true);

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions