summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKjartan Mannes <kjartan@2.no-reply.drupal.org>2004-04-21 11:31:34 +0000
committerKjartan Mannes <kjartan@2.no-reply.drupal.org>2004-04-21 11:31:34 +0000
commit7976678719f6e04ecda315a6088ee0eb3cfb0318 (patch)
treeb7c143b9d4419a2a10128b460e80db93d0036028
parent291b56c0ccbbdfc5505b6ea391153e363ff19d3b (diff)
downloadbrdo-7976678719f6e04ecda315a6088ee0eb3cfb0318.tar.gz
brdo-7976678719f6e04ecda315a6088ee0eb3cfb0318.tar.bz2
- Only encode strings that contain non-ASCII characters.
-rw-r--r--modules/user.module11
-rw-r--r--modules/user/user.module11
2 files changed, 14 insertions, 8 deletions
diff --git a/modules/user.module b/modules/user.module
index e6a940f2c..ab3194599 100644
--- a/modules/user.module
+++ b/modules/user.module
@@ -280,6 +280,7 @@ function user_mail_encode($string, $charset = "UTF-8") {
** http://www.rfc-editor.org/rfc/rfc2047.txt
**
** Notes:
+ ** - Only encode strings that contain non-ASCII characters.
** - The chunks come in groupings of 4 bytes when using base64
** encoded.
** - trim() is used to ensure that no extra spacing is added by
@@ -287,10 +288,12 @@ function user_mail_encode($string, $charset = "UTF-8") {
** - Using \n as the chunk separator may cause problems on some
** systems and may have to be changed to \r\n or \r.
*/
- $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));
+ if (!preg_match('/^[\x20-\x7E]*$/', $string)) {
+ $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 e6a940f2c..ab3194599 100644
--- a/modules/user/user.module
+++ b/modules/user/user.module
@@ -280,6 +280,7 @@ function user_mail_encode($string, $charset = "UTF-8") {
** http://www.rfc-editor.org/rfc/rfc2047.txt
**
** Notes:
+ ** - Only encode strings that contain non-ASCII characters.
** - The chunks come in groupings of 4 bytes when using base64
** encoded.
** - trim() is used to ensure that no extra spacing is added by
@@ -287,10 +288,12 @@ function user_mail_encode($string, $charset = "UTF-8") {
** - Using \n as the chunk separator may cause problems on some
** systems and may have to be changed to \r\n or \r.
*/
- $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));
+ if (!preg_match('/^[\x20-\x7E]*$/', $string)) {
+ $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;
}