diff --git a/core/lib/Drupal/Component/Utility/Unicode.php b/core/lib/Drupal/Component/Utility/Unicode.php index f344b78..fd713e4 100644 --- a/core/lib/Drupal/Component/Utility/Unicode.php +++ b/core/lib/Drupal/Component/Utility/Unicode.php @@ -590,7 +590,7 @@ public static function strcasecmp($str1 , $str2) { } /** - * Encodes MIME/HTTP headers that contain unencoded characters. + * Encodes MIME/HTTP headers containing characters that should be encoded. * * For example, Unicode::mimeHeaderEncode('tést.txt') returns * "=?UTF-8?B?dMOpc3QudHh0?=". @@ -602,6 +602,13 @@ public static function strcasecmp($str1 , $str2) { * - We progressively cut-off a chunk with self::truncateBytes(). This ensures * each chunk starts and ends on a character boundary. * - According to RFC 2047, we split long lines using CLRF SPACE as separator. + * - PHP's mail() function (http://php.net/manual/en/function.mail.php) used + * to have an explicit restriction that subject lines could not contain LF. + * This restriction has been lifted since november 2009 or earlier, but + * occasional problem reports have still popped up about a system not being + * able to deal with "\n" in subject lines, whose source (php or mailer) was + * not confirmed. See https://www.drupal.org/node/300387#comment-7701323 + * and please report details there in case of problems. * * @param string $string * The header to encode. @@ -613,9 +620,10 @@ public static function mimeHeaderEncode($string) { if (preg_match('/[^\x20-\x7E]/', $string)) { // Encoded lines must be 75 characters or less; base64 expands to 4/3 // times the line size (in bytes), rounded up to a multiple of 4, so: - // ceil($chunk_size * 4/3) must be <= 75 - strlen("=?UTF-8?B??=") - // => floor(($chunk_size + 2/3) * 4/3) must be <= 63 - $chunk_size = 45; // floor((63 * 3/4) - 3/2) + // ceil($chunk_size / 3) * 4 must be <= 75 - strlen("=?UTF-8?B??=") + // => ceil($chunk_size / 3) must be <= 63 / 4 + // => $chunk_size must be <= floor(63 / 4) * 3 + $chunk_size = 45; $len = strlen($string); $output = ''; while ($len > 0) {