Skip to content

Commit

Permalink
[5.1] Fix attachment handling in libraries Mail class (joomla#43828)
Browse files Browse the repository at this point in the history
  • Loading branch information
LadySolveig authored Jul 23, 2024
1 parent 183985b commit dabf3fe
Showing 1 changed file with 3 additions and 11 deletions.
14 changes: 3 additions & 11 deletions libraries/src/Mail/Mail.php
Original file line number Diff line number Diff line change
Expand Up @@ -401,28 +401,20 @@ public function addAttachment($path, $name = '', $encoding = 'base64', $type = '
$result = true;

if (\is_array($path)) {
if (!empty($name) && \count($path) != \count($name)) {
if (!empty($name) && \is_array($name) && \count($path) != \count($name)) {
throw new \InvalidArgumentException('The number of attachments must be equal with the number of name');
}

foreach ($path as $key => $file) {
if (!empty($name)) {
$result = parent::addAttachment($file, $name[$key], $encoding, $type);
} else {
if (!empty($name)) {
$result = parent::addAttachment($file, $name[$key], $encoding, $type, $disposition);
} else {
$result = parent::addAttachment($file, $name, $encoding, $type, $disposition);
}
}
$result = parent::addAttachment($file, isset($name[$key]) ? $name[$key] : '', $encoding, $type, $disposition);
}

// Check for boolean false return if exception handling is disabled
if ($result === false) {
return false;
}
} else {
$result = parent::addAttachment($path, $name, $encoding, $type);
$result = parent::addAttachment($path, $name, $encoding, $type, $disposition);
}

// Check for boolean false return if exception handling is disabled
Expand Down

0 comments on commit dabf3fe

Please sign in to comment.