Skip to content

Commit b2d43a1

Browse files
committed
email notification
- revert to utf8 encoding as in phpBB 3.3.4
1 parent b18eeb1 commit b2d43a1

File tree

1 file changed

+6
-15
lines changed

1 file changed

+6
-15
lines changed

includes/functions_messenger.php

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1848,27 +1848,18 @@ function digest_md5($username, $password)
18481848
*
18491849
* Please note that this version fully supports RFC 2045 section 6.8.
18501850
*
1851-
* @param string $str
18521851
* @param string $eol End of line we are using (optional to be backwards compatible)
18531852
*/
18541853
function mail_encode($str, $eol = "\r\n")
18551854
{
1856-
// Check if string contains ASCII only characters
1857-
$is_ascii = strlen($str) === utf8_strlen($str);
1858-
1859-
// Define start delimimter, end delimiter and spacer
1860-
// Use the Quoted-Printable encoding for ASCII strings to avoid unnecessary encoding in Base64
1861-
$start = $is_ascii ? "=?US-ASCII?Q?" : "=?UTF-8?B?";
1855+
// define start delimimter, end delimiter and spacer
1856+
$start = "=?UTF-8?B?";
18621857
$end = "?=";
18631858
$delimiter = "$eol ";
18641859

1865-
// Maximum encoded-word length is 75 as per RFC 2047 section 2.
1866-
// $split_length *must* be a multiple of 4, but <= 75 - strlen($start . $delimiter . $end)!!!
1867-
$split_length = 75 - strlen($start . $delimiter . $end);
1868-
$split_length = $split_length - $split_length % 4;
1869-
1870-
// Use the Quoted-Printable encoding for ASCII strings to avoid unnecessary encoding in Base64
1871-
$encoded_str = $is_ascii ? quoted_printable_encode($str) : base64_encode($str);
1860+
// Maximum length is 75. $split_length *must* be a multiple of 4, but <= 75 - strlen($start . $delimiter . $end)!!!
1861+
$split_length = 60;
1862+
$encoded_str = base64_encode($str);
18721863

18731864
// If encoded string meets the limits, we just return with the correct data.
18741865
if (strlen($encoded_str) <= $split_length)
@@ -1877,7 +1868,7 @@ function mail_encode($str, $eol = "\r\n")
18771868
}
18781869

18791870
// If there is only ASCII data, we just return what we want, correctly splitting the lines.
1880-
if ($is_ascii)
1871+
if (strlen($str) === utf8_strlen($str))
18811872
{
18821873
return $start . implode($end . $delimiter . $start, str_split($encoded_str, $split_length)) . $end;
18831874
}

0 commit comments

Comments
 (0)