[Mime] Ensure proper line-ending for SMIME

This commit is contained in:
Sebastiaan 2020-04-16 13:29:30 +02:00 committed by Sebastiaan Stok
parent 4f8f3747d3
commit 5e3ccc2814
No known key found for this signature in database
GPG Key ID: AEE24F70006C92F7
2 changed files with 6 additions and 2 deletions

View File

@ -65,7 +65,7 @@ abstract class SMime
protected function getStreamIterator($stream): iterable
{
while (!feof($stream)) {
yield fread($stream, 16372);
yield str_replace("\n", "\r\n", str_replace("\r\n", "\n", fread($stream, 16372)));
}
}

View File

@ -87,7 +87,11 @@ class SMimeEncryptorTest extends SMimeTestCase
private function assertMessageIsEncryptedProperly(Message $message, Message $originalMessage): void
{
$messageFile = $this->generateTmpFilename();
file_put_contents($messageFile, $message->toString());
file_put_contents($messageFile, $messageString = $message->toString());
// Ensure the proper line-ending is used for compatibility with the RFC
$this->assertStringContainsString("\n\r", $messageString);
$this->assertStringNotContainsString("\n\n", $messageString);
$outputFile = $this->generateTmpFilename();