summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKjartan Mannes <kjartan@2.no-reply.drupal.org>2003-10-04 12:59:46 +0000
committerKjartan Mannes <kjartan@2.no-reply.drupal.org>2003-10-04 12:59:46 +0000
commit934938c486a6664c98c5d92aad255190e440a344 (patch)
tree778dea4ba28251535554bfcf2e82f7d18f58d883
parent988da0f13633db4539edbdbbd56f64d2ad184202 (diff)
downloadbrdo-934938c486a6664c98c5d92aad255190e440a344.tar.gz
brdo-934938c486a6664c98c5d92aad255190e440a344.tar.bz2
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.
-rw-r--r--modules/user.module13
-rw-r--r--modules/user/user.module13
2 files changed, 22 insertions, 4 deletions
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;
}
diff --git a/modules/user/user.module b/modules/user/user.module
index fc604a51a..221901fd7 100644
--- a/modules/user/user.module
+++ b/modules/user/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;
}