bug #36463 [Mime] Ensure proper line-ending for SMIME (sstok)

This PR was merged into the 5.0 branch.

Discussion
----------

[Mime] Ensure proper line-ending for SMIME

| Q             | A
| ------------- | ---
| Branch?       | 5.0
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | Fix #36398
| License       | MIT
| Doc PR        |

Commits
-------

5e3ccc2814 [Mime] Ensure proper line-ending for SMIME
This commit is contained in:
Fabien Potencier 2020-04-17 05:29:44 +02:00
commit 6f81e03331
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();