8000 [Mime] Ensure proper line-ending for SMIME by sstok · Pull Request #36463 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Mime] Ensure proper line-ending for SMIME #36463

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Symfony/Component/Mime/Crypto/SMime.php
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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