diff options
Diffstat (limited to 'modules/user/user.module')
-rw-r--r-- | modules/user/user.module | 34 |
1 files changed, 11 insertions, 23 deletions
diff --git a/modules/user/user.module b/modules/user/user.module index 6d7a97f80..fc604a51a 100644 --- a/modules/user/user.module +++ b/modules/user/user.module @@ -324,33 +324,21 @@ function user_mail($mail, $subject, $message, $header) { $mail, user_mail_encode($subject), str_replace("\r", "", $message), - "MIME-version: 1.0\nContent-type: text/plain; charset=UTF-8; format=flowed\nContent-transfer-encoding: 8BIT\n" . $header + "MIME-Version: 1.0\nContent-type: text/plain; charset=UTF-8; format=flowed\nContent-transfer-encoding: 8Bit\n" . $header ); } } -// Original code by <gordon at kanazawa-gu dot ac dot jp> -function user_mail_encode($string) { - - // define start delimimter, end delimiter and spacer - $end = "?="; - $start = "=?UTF-8?B?"; - $spacer = "{$end}\r\n{$start}"; - - // determine length of encoded text within - // chunks and ensure length is even - $length = 75 - strlen($start) - strlen($end); - $length = floor($length/2) * 2; - - // encode the string and split it into chunks - // with spacers after each chunk - $string = base64_encode($string); - $string = chunk_split($string, $length, $spacer); - - // remove trailing spacer and add start and end delimiters - $spacer = preg_quote($spacer); - $string = preg_replace("/{$spacer}$/", "", $string); - return ($start . $string . $end); +function user_mail_encode($string, $charset = "UTF-8") { + /* + ** Used to encodes mail headers that contain non US- ASCII + ** characters. + ** http://www.rfc-editor.org/rfc/rfc2047.txt + */ + $maxlen = 75 - 7 - strlen($charset); + $string = trim(chunk_split(base64_encode($string), $maxlen, "\n")); + $string = trim(preg_replace('/^(.*)$/m', " =?$charset?B?\\1?=", $string)); + return $string; } function user_deny($type, $mask) { |