Commit 7531e829 authored by Dries's avatar Dries

- Made sure non US-ASCII mails are sent out properly.  Patch by Gabor.

  TODO: rename user_mail() to drupal_mail() and move it to common.inc.
  Other modules, such as the project module, should use this as well
  or they risk to send out /invalid/ mails.
parent d80140b4
...@@ -311,10 +311,39 @@ function user_mail($mail, $subject, $message, $header) { ...@@ -311,10 +311,39 @@ function user_mail($mail, $subject, $message, $header) {
** http://www.rfc-editor.org/rfc/rfc2646.txt ** http://www.rfc-editor.org/rfc/rfc2646.txt
** **
*/ */
return mail($mail, $subject, str_replace("\r", "", $message), $header); return mail(
$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
);
} }
} }
// 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_deny($type, $mask) { function user_deny($type, $mask) {
$allow = db_fetch_object(db_query("SELECT * FROM {access} WHERE status = '1' AND type = '%s' AND LOWER('%s') LIKE LOWER(mask)", $type, $mask)); $allow = db_fetch_object(db_query("SELECT * FROM {access} WHERE status = '1' AND type = '%s' AND LOWER('%s') LIKE LOWER(mask)", $type, $mask));
......
...@@ -311,10 +311,39 @@ function user_mail($mail, $subject, $message, $header) { ...@@ -311,10 +311,39 @@ function user_mail($mail, $subject, $message, $header) {
** http://www.rfc-editor.org/rfc/rfc2646.txt ** http://www.rfc-editor.org/rfc/rfc2646.txt
** **
*/ */
return mail($mail, $subject, str_replace("\r", "", $message), $header); return mail(
$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
);
} }
} }
// 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_deny($type, $mask) { function user_deny($type, $mask) {
$allow = db_fetch_object(db_query("SELECT * FROM {access} WHERE status = '1' AND type = '%s' AND LOWER('%s') LIKE LOWER(mask)", $type, $mask)); $allow = db_fetch_object(db_query("SELECT * FROM {access} WHERE status = '1' AND type = '%s' AND LOWER('%s') LIKE LOWER(mask)", $type, $mask));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment