Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 52ceda7

Browse filesBrowse files
alamiraultfabpot
authored andcommitted
[Mime] Fix missing sprintf in DkimSigner
1 parent 6a5db15 commit 52ceda7
Copy full SHA for 52ceda7

File tree

2 files changed

+18
-2
lines changed
Filter options

2 files changed

+18
-2
lines changed

‎src/Symfony/Component/Mime/Crypto/DkimSigner.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Mime/Crypto/DkimSigner.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public function sign(Message $message, array $options = []): Message
6565
{
6666
$options += $this->defaultOptions;
6767
if (!\in_array($options['algorithm'], [self::ALGO_SHA256, self::ALGO_ED25519], true)) {
68-
throw new InvalidArgumentException('Invalid DKIM signing algorithm "%s".', $options['algorithm']);
68+
throw new InvalidArgumentException(sprintf('Invalid DKIM signing algorithm "%s".', $options['algorithm']));
6969
}
7070
$headersToIgnore['return-path'] = true;
7171
$headersToIgnore['x-transport'] = true;
@@ -205,7 +205,7 @@ private function hashBody(AbstractPart $body, string $bodyCanon, int $maxLength)
205205
}
206206

207207
// Add trailing Line return if last line is non empty
208-
if (\strlen($currentLine) > 0) {
208+
if ('' !== $currentLine) {
209209
hash_update($hash, "\r\n");
210210
$length += \strlen("\r\n");
211211
}

‎src/Symfony/Component/Mime/Tests/Crypto/DkimSignerTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Mime/Tests/Crypto/DkimSignerTest.php
+16Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use Symfony\Component\Mime\Address;
1717
use Symfony\Component\Mime\Crypto\DkimSigner;
1818
use Symfony\Component\Mime\Email;
19+
use Symfony\Component\Mime\Message;
1920

2021
/**
2122
* @group time-sensitive
@@ -90,6 +91,21 @@ public function getSignData()
9091
];
9192
}
9293

94+
public function testSignWithUnsupportedAlgorithm()
95+
{
96+
$message = $this->createMock(Message::class);
97+
98+
$signer = new DkimSigner(self::$pk, 'testdkim.symfony.net', 'sf', [
99+
'algorithm' => 'unsupported-value',
100+
]);
101+
102+
$this->expectExceptionObject(
103+
new \LogicException('Invalid DKIM signing algorithm "unsupported-value".')
104+
);
105+
106+
$signer->sign($message, []);
107+
}
108+
93109
/**
94110
* @dataProvider getCanonicalizeHeaderData
95111
*/

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.