laminas / laminas-mime

Create and parse MIME messages and parts
https://docs.laminas.dev/laminas-mime/
BSD 3-Clause "New" or "Revised" License
29 stars 23 forks source link

Cannot get attachment filename using createFromMessage to parse eml #32

Closed mathsgod closed 2 years ago

mathsgod commented 2 years ago

Message::createFromMessage cannot get attachment filename in parts

How to reproduce

create test.eml

Content-Type: application/text; name=hello.txt
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename=hello.txt

aGVsbG8gd29ybGQh

php

use Laminas\Mime\Message;
$message = Message::createFromMessage(file_get_contents('test.eml');
print_r($message->getParts());

echo $message->getParts()[0]->getFileName();  // empty output

output

Array
(
    [0] => Laminas\Mime\Part Object
        (
            [type] => application/text;
 name="hello.txt"
            [encoding] => base64
            [id] =>
            [disposition] => attachment; filename="hello.txt"
            [filename] =>
            [description] =>
            [charset] =>
            [boundary] =>
            [location] =>
            [language] =>
            [content:protected] => hello world!
            [isStream:protected] =>
            [filters:protected] => Array
                (
                )

        )

)

Expected behavior

Array
(
    [0] => Laminas\Mime\Part Object
        (
            [type] => application/text;
 name="hello.txt"
            [encoding] => base64
            [id] =>
            [disposition] => attachment
            [filename] => hello.txt
            [description] =>
            [charset] =>
            [boundary] =>
            [location] =>
            [language] =>
            [content:protected] => hello world!
            [isStream:protected] =>
            [filters:protected] => Array
                (
                )

        )

)
laminas-bot commented 2 years ago

This package is considered feature-complete, and is now in security-only maintenance mode, following a decision by the Technical Steering Committee. If you have a security issue, please follow our security reporting guidelines. If you wish to take on the role of maintainer, please nominate yourself

If you are looking for an actively maintained package alternative, we recommend: