-
-
Notifications
You must be signed in to change notification settings - Fork 9.8k
Closed
Description
Symfony 4.3
We miss name of the TextPart attachments while preparing multidimensional arrays inside FormDataPart.
To reproduce it just send multiple attachments with custom name with FormDataPart.
For example, I took code from symfony/mailer-mailgun:
$body = new FormDataPart($this->getPayload($email, $envelope));
...
private function getPayload(Email $email, SmtpEnvelope $envelope): array
{
...
$payload = [
'from' => $envelope->getSender()->toString(),
'to' => implode(',', $this->stringifyAddresses($this->getRecipients($email, $envelope))),
'subject' => $email->getSubject(),
/** i'm talking about these 2 params */
'attachment' => $attachments,
'inline' => $inlines,
];
...
}
As a result the request attachments will be without name (or with indexed as 0,1,2.. names).
It happens, because we miss parent key name in FormDataPart::prepareFields method.
private function prepareFields(array $fields): array
{
$values = [];
array_walk_recursive($fields, function ($item, $key) use (&$values) {
if (!\is_array($item)) {
$values[] = $this->preparePart($key, $item);
}
});
return $values;
}