From 934938c486a6664c98c5d92aad255190e440a344 Mon Sep 17 00:00:00 2001 From: Kjartan Mannes Date: Sat, 4 Oct 2003 12:59:46 +0000 Subject: user_mail_encode() fixes: - Made sure the chunk sizes always include groupings of 4 bytes. - Added more comments so fixes are not lost in future changes. --- modules/user.module | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'modules/user.module') diff --git a/modules/user.module b/modules/user.module index fc604a51a..221901fd7 100644 --- a/modules/user.module +++ b/modules/user.module @@ -334,9 +334,18 @@ 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 + ** + ** Notes: + ** - The chunks come in groupings of 4 bytes when using base64 + ** encoded. + ** - trim() is used to ensure that no extra spacing is added by + ** chunk_split() or preg_replace(). + ** - Using \n as the chunk separator may cause problems on some + ** systems and may have to be changed to \r\n or \r. */ - $maxlen = 75 - 7 - strlen($charset); - $string = trim(chunk_split(base64_encode($string), $maxlen, "\n")); + $chunk_size = 75 - 7 - strlen($charset); + $chunk_size -= $chunk_size % 4; + $string = trim(chunk_split(base64_encode($string), $chunk_size, "\n")); $string = trim(preg_replace('/^(.*)$/m', " =?$charset?B?\\1?=", $string)); return $string; } -- cgit v1.2.3