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 ad1ff4f

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

File tree

Expand file treeCollapse file tree

2 files changed

+9
-3
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+9
-3
lines changed

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Mime/Crypto/DkimSigner.php
+7-1Lines 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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Mime/Tests/Crypto/DkimSignerTest.php
+2-2Lines 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)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.