[Mime] Fix compat with HTTP requests

This commit is contained in:
Fabien Potencier 2020-07-15 08:42:27 +02:00
parent 05fe56b88e
commit 52e7d7cf17
2 changed files with 3 additions and 2 deletions

View File

@ -158,7 +158,8 @@ final class ParameterizedHeader extends UnstructuredHeader
*/
private function getEndOfParameterValue(string $value, bool $encoded = false, bool $firstLine = false): string
{
if (!preg_match('/^'.self::TOKEN_REGEX.'$/D', $value)) {
$forceHttpQuoting = 'content-disposition' === strtolower($this->getName()) && 'form-data' === $this->getValue();
if ($forceHttpQuoting || !preg_match('/^'.self::TOKEN_REGEX.'$/D', $value)) {
$value = '"'.$value.'"';
}
$prepend = '=';

View File

@ -129,7 +129,7 @@ class TextPart extends AbstractPart
if ($this->charset) {
$headers->setHeaderParameter('Content-Type', 'charset', $this->charset);
}
if ($this->name) {
if ($this->name && 'form-data' !== $this->disposition) {
$headers->setHeaderParameter('Content-Type', 'name', $this->name);
}
$headers->setHeaderBody('Text', 'Content-Transfer-Encoding', $this->encoding);