8000 Add trailing Line return if last line is non empty · rtek/symfony@ad1ff4f · GitHub
[go: up one dir, main page]

Skip to content

Commit ad1ff4f

Browse files
metaerfabpot
authored andcommitted
Add trailing Line return if last line is non empty
1 parent 2b0c65f commit ad1ff4f

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,13 @@ private function hashBody(AbstractPart $body, string $bodyCanon, int $maxLength)
203203
hash_update($hash, $canon);
204204
}
205205

206-
if (0 === $length) {
206+
// Add trailing Line return if last line is non empty
207+
if (\strlen($currentLine) > 0) {
208+
hash_update($hash, "\r\n");
209+
$length += \strlen("\r\n");
210+
}
211+
212+
if (!$relaxed && 0 === $length) {
207213
hash_update($hash, "\r\n");
208214
$length = 2;
209215
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,14 +122,14 @@ public function getCanonicalizeHeaderData()
122122
DkimSigner::CANON_SIMPLE, "\r\n", '', \PHP_INT_MAX,
123123
];
124124
yield 'relaxed_empty' => [
125-
DkimSigner::CANON_RELAXED, "\r\n", '', \PHP_INT_MAX,
125+
DkimSigner::CANON_RELAXED, '', '', \PHP_INT_MAX,
126126
];
127127

128128
yield 'simple_empty_single_ending_CLRF' => [
129129
DkimSigner::CANON_SIMPLE, "\r\n", "\r\n", \PHP_INT_MAX,
130130
];
131131
yield 'relaxed_empty_single_ending_CLRF' => [
132-
DkimSigner::CANON_RELAXED, "\r\n", "\r\n", \PHP_INT_MAX,
132+
DkimSigner::CANON_RELAXED, '', "\r\n", \PHP_INT_MAX,
133133
];
134134

135135
yield 'simple_multiple_ending_CLRF' => [

0 commit comments

Comments
 (0)
0