Skip to content

Commit

Permalink
bug #36463 [Mime] Ensure proper line-ending for SMIME (sstok)
Browse files Browse the repository at this point in the history
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
-------

5e3ccc2 [Mime] Ensure proper line-ending for SMIME
  • Loading branch information
fabpot committed Apr 17, 2020
2 parents 3b4c41f + 5e3ccc2 commit 6f81e03
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Symfony/Component/Mime/Crypto/SMime.php
Expand Up @@ -65,7 +65,7 @@ protected function convertMessageToSMimePart($stream, string $type, string $subt
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)));
}
}

Expand Down
Expand Up @@ -87,7 +87,11 @@ public function testEncryptMessageWithMultipleCerts()
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();

Expand Down

0 comments on commit 6f81e03

Please sign in to comment.