8000 [Mime] Fix missing sprintf in DkimSigner · symfony/symfony@52ceda7 · GitHub
[go: up one dir, main page]

Skip to content

Commit 52ceda7

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

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

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

Lines 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

Lines 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