8000 [Mime] Ensure proper line-ending for SMIME · symfony/symfony@5e3ccc2 · GitHub
[go: up one dir, main page]

Skip to content

Commit 5e3ccc2

Browse files
committed
[Mime] Ensure proper line-ending for SMIME
1 parent 4f8f374 commit 5e3ccc2

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/Symfony/Component/Mime/Crypto/SMime.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ protected function convertMessageToSMimePart($stream, string $type, string $subt
6565
protected function getStreamIterator($stream): iterable
6666
{
6767
while (!feof($stream)) {
68-
yield fread($stream, 16372);
68+
yield str_replace("\n", "\r\n", str_replace("\r\n", "\n", fread($stream, 16372)));
6969
}
7070
}
7171

src/Symfony/Component/Mime/Tests/Crypto/SMimeEncryptorTest.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,11 @@ public function testEncryptMessageWithMultipleCerts()
8787
private function assertMessageIsEncryptedProperly(Message $message, Message $originalMessage): void
8888
{
8989
$messageFile = $this->generateTmpFilename();
90-
file_put_contents($messageFile, $message->toString());
90+
file_put_contents($messageFile, $messageString = $message->toString());
91+
92+
// Ensure the proper line-ending is used for compatibility with the RFC
93+
$this->assertStringContainsString("\n\r", $messageString);
94+
$this->assertStringNotContainsString("\n\n", $messageString);
9195

9296
$outputFile = $this->generateTmpFilename();
9397

0 commit comments

Comments
 (0)
0