? sites/default/files ? sites/default/settings.php Index: includes/unicode.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/unicode.inc,v retrieving revision 1.30 diff -u -p -r1.30 unicode.inc --- includes/unicode.inc 14 Apr 2008 17:48:33 -0000 1.30 +++ includes/unicode.inc 10 Jun 2008 00:27:38 -0000 @@ -270,13 +270,20 @@ function truncate_utf8($string, $len, $w * See http://www.rfc-editor.org/rfc/rfc2047.txt for more information. * * Notes: - * - Only encode strings that contain non-ASCII characters. + * - Only encode strings that contain non-ASCII characters, unless the optional + * second parameter is defined, in which case perform quoted-string encoding + * on strings containing non-alphanumeric ASCII characters. * - We progressively cut-off a chunk with truncate_utf8(). This is to ensure * each chunk starts and ends on a character boundary. * - Using \n as the chunk separator may cause problems on some systems and may * have to be changed to \r\n or \r. + * + * @param $string + * The string to encode. + * @param $quoted + * If set, perform quoted-string encoding of non-alphanumeric ASCII. */ -function mime_header_encode($string) { +function mime_header_encode($string, $quoted = FALSE) { if (preg_match('/[^\x20-\x7E]/', $string)) { $chunk_size = 47; // floor((75 - strlen("=?UTF-8?B??=")) * 0.75); $len = strlen($string); @@ -290,6 +297,12 @@ function mime_header_encode($string) { } return trim($output); } + // Strings containing spaces and certain other characters must in some cases + // be quoted-string encoded. + if ($quoted && preg_match('/[^A-Za-z0-9_]/', $string)) { + // Escape double-quotes and backslashes. + return '"' . addcslashes($string, '\"') . '"'; + } return $string; }