Skip to content
This repository has been archived by the owner on Nov 22, 2024. It is now read-only.

Adding a duplicate part to a message should not be permitted #19

Closed
jamesshaw1987 opened this issue Sep 20, 2021 · 2 comments
Closed

Adding a duplicate part to a message should not be permitted #19

jamesshaw1987 opened this issue Sep 20, 2021 · 2 comments
Assignees
Labels
Bug Something isn't working Won't Fix This will not be worked on

Comments

@jamesshaw1987
Copy link

Bug Report

Q A
Version(s) 2.9.0

Summary

The change to use a strict comparison in \Laminas\Mime\Message::addPart (if ($part === $row) {) means that the given $part can contain the exact same data as the existing $row, but an exception will only be throw if they're the same instance. It shouldn't be possible to add two parts containing identical data.

How to reproduce

$part1 = (new \Laminas\Mime\Part('DATA'))->setId('ID');
$part2 = (new \Laminas\Mime\Part('DATA'))->setId('ID');

$message = new \Laminas\Mime\Message();
$message->addPart($part1);
$message->addPart($part2); // should throw \Laminas\Mime\Exception\InvalidArgumentException with message 'Provided part ID already defined.'

Workaround

For now, this can easily be worked around by doing something like:

$message = new \Laminas\Mime\Message();
$message->addPart($part1);

if (in_array($part1, $message->getParts())) {
    return;
}

$message->addPart($part2); 
@jamesshaw1987 jamesshaw1987 added the Bug Something isn't working label Sep 20, 2021
@laminas-bot
Copy link
Contributor

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:

@gsteel
Copy link
Member

gsteel commented Nov 22, 2024

@gsteel gsteel closed this as completed Nov 22, 2024
@gsteel gsteel added the Won't Fix This will not be worked on label Nov 22, 2024
@gsteel gsteel self-assigned this Nov 22, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug Something isn't working Won't Fix This will not be worked on
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants