diff --git a/src/Symfony/Component/Mime/Part/AbstractMultipartPart.php b/src/Symfony/Component/Mime/Part/AbstractMultipartPart.php index 48b8620232c49..685d250627e43 100644 --- a/src/Symfony/Component/Mime/Part/AbstractMultipartPart.php +++ b/src/Symfony/Component/Mime/Part/AbstractMultipartPart.php @@ -91,7 +91,7 @@ public function asDebugString(): string private function getBoundary(): string { if (null === $this->boundary) { - $this->boundary = '_=_symfony_'.time().'_'.bin2hex(random_bytes(16)).'_=_'; + $this->boundary = strtr(base64_encode(random_bytes(6)), '+/', '-_'); } return $this->boundary; diff --git a/src/Symfony/Component/Mime/Tests/Part/Multipart/FormDataPartTest.php b/src/Symfony/Component/Mime/Tests/Part/Multipart/FormDataPartTest.php index a74ecea316ec9..dbc2e6eff9a22 100644 --- a/src/Symfony/Component/Mime/Tests/Part/Multipart/FormDataPartTest.php +++ b/src/Symfony/Component/Mime/Tests/Part/Multipart/FormDataPartTest.php @@ -91,4 +91,16 @@ public function testContentLineLength() $this->assertEquals($foo, $parts[0]->bodyToString()); $this->assertEquals($bar, $parts[1]->bodyToString()); } + + public function testBoundaryContentTypeHeader() + { + $f = new FormDataPart([ + 'file' => new DataPart('data.csv', 'data.csv', 'text/csv'), + ]); + $headers = $f->getPreparedHeaders()->toArray(); + $this->assertRegExp( + '/^Content-Type: multipart\/form-data; boundary=[a-zA-Z0-9\-_]{8}$/', + $headers[0] + ); + } }
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies: