diff --git a/phpBB/docs/CHANGELOG.html b/phpBB/docs/CHANGELOG.html
index e9f5994a7c..e592031c14 100644
--- a/phpBB/docs/CHANGELOG.html
+++ b/phpBB/docs/CHANGELOG.html
@@ -136,6 +136,7 @@
[Fix] Prevent incomplete backups stored if option "store and download" is selected and admin cancel download by removing the option. (Bug #20325)
[Fix] Enforce correct case for template variables
[Fix] Set topic_last_view_time on post/reply/edit to circumvent race conditions in auto prune and false removal of topics for manual forum prune (Bug #18055, #43515)
+ [Fix] Correctly split long subject lines according to the used RFC. This fixes extra spaces within long subjects. (Bug #43715)
[Change] Allow download of conflicting file for later reference in automatic updater
[Change] Default difference view is now 'inline' instead of 'side by side'
[Change] Added new option for merging differences to conflicting files in automatic updater
diff --git a/phpBB/includes/functions_messenger.php b/phpBB/includes/functions_messenger.php
index 866acc7f1a..aad064d5e6 100644
--- a/phpBB/includes/functions_messenger.php
+++ b/phpBB/includes/functions_messenger.php
@@ -1446,9 +1446,10 @@ function mail_encode($str)
// define start delimimter, end delimiter and spacer
$start = "=?UTF-8?B?";
$end = "?=";
- $spacer = $end . ' ' . $start;
- $split_length = 64;
+ $delimiter = "\r\n ";
+ // Maximum length is 75 for everything. 75 - length of start/end/delimiter == 63
+ $split_length = 63;
$encoded_str = base64_encode($str);
// If encoded string meets the limits, we just return with the correct data.
@@ -1460,7 +1461,7 @@ function mail_encode($str)
// If there is only ASCII data, we just return what we want, correctly splitting the lines.
if (strlen($str) === utf8_strlen($str))
{
- return $start . implode($spacer, str_split($encoded_str, $split_length)) . $end;
+ return $start . implode($end . $delimiter . $start, str_split($encoded_str, $split_length)) . $end;
}
// UTF-8 data, compose encoded lines
@@ -1476,10 +1477,10 @@ function mail_encode($str)
$text .= array_shift($array);
}
- $str .= $start . base64_encode($text) . $end . ' ';
+ $str .= $start . base64_encode($text) . $end . $delimiter;
}
- return substr($str, 0, -1);
+ return substr($str, 0, -strlen($delimiter));
}
?>
\ No newline at end of file