Index: functions/strings.php
===================================================================
--- functions/strings.php	(revision 13924)
+++ functions/strings.php	(working copy)
@@ -141,7 +141,7 @@
   * Truncates the given string so that it has at
   * most $max_chars characters.  NOTE that a "character"
   * may be a multibyte character, or (optionally), an
-  * HTML entity , so this function is different than
+  * HTML entity, so this function is different than
   * using substr() or mb_substr().
   * 
   * NOTE that if $elipses is given and used, the returned
@@ -814,16 +814,16 @@
    //
    if ($charset == 'auto')
    {
-//FIXME: is there any reason why this cannot be a global flag used by all string wrapper functions?
-      static $auto_charset;
-      if (!isset($auto_charset))
+//FIXME: this may or may not be better as a session value instead of a global one
+      global $sq_string_func_auto_charset;
+      if (!isset($sq_string_func_auto_charset))
       {
          global $default_charset, $squirrelmail_language;
          set_my_charset();
-         $auto_charset = $default_charset;
-         if ($squirrelmail_language == 'ja_JP') $auto_charset = 'euc-jp';
+         $sq_string_func_auto_charset = $default_charset;
+         if ($squirrelmail_language == 'ja_JP') $sq_string_func_auto_charset = 'euc-jp';
       }
-      $charset = $auto_charset;
+      $charset = $sq_string_func_auto_charset;
    }
 
 
@@ -894,16 +894,16 @@
    //
    if ($charset == 'auto')
    {
-//FIXME: is there any reason why this cannot be a global flag used by all string wrapper functions?
-      static $auto_charset;
-      if (!isset($auto_charset))
+//FIXME: this may or may not be better as a session value instead of a global one
+      global $sq_string_func_auto_charset;
+      if (!isset($sq_string_func_auto_charset))
       {
          global $default_charset, $squirrelmail_language;
          set_my_charset();
-         $auto_charset = $default_charset;
-         if ($squirrelmail_language == 'ja_JP') $auto_charset = 'euc-jp';
+         $sq_string_func_auto_charset = $default_charset;
+         if ($squirrelmail_language == 'ja_JP') $sq_string_func_auto_charset = 'euc-jp';
       }
-      $charset = $auto_charset;
+      $charset = $sq_string_func_auto_charset;
    }
 
 
@@ -987,16 +987,16 @@
    //
    if ($charset == 'auto')
    {
-//FIXME: is there any reason why this cannot be a global flag used by all string wrapper functions?
-      static $auto_charset;
-      if (!isset($auto_charset))
+//FIXME: this may or may not be better as a session value instead of a global one
+      global $sq_string_func_auto_charset;
+      if (!isset($sq_string_func_auto_charset))
       {
          global $default_charset, $squirrelmail_language;
          set_my_charset();
-         $auto_charset = $default_charset;
-         if ($squirrelmail_language == 'ja_JP') $auto_charset = 'euc-jp';
+         $sq_string_func_auto_charset = $default_charset;
+         if ($squirrelmail_language == 'ja_JP') $sq_string_func_auto_charset = 'euc-jp';
       }
-      $charset = $auto_charset;
+      $charset = $sq_string_func_auto_charset;
    }
 
 
@@ -1075,16 +1075,17 @@
    //
    if ($charset == 'auto')
    {
-//FIXME: is there any reason why this cannot be a global flag used by all string wrapper functions?
-      static $auto_charset;
-      if (!isset($auto_charset))
+//FIXME: this may or may not be better as a session value instead of a global one
+      $charset = $auto_charset;
+      global $sq_string_func_auto_charset;
+      if (!isset($sq_string_func_auto_charset))
       {
          global $default_charset, $squirrelmail_language;
          set_my_charset();
-         $auto_charset = $default_charset;
-         if ($squirrelmail_language == 'ja_JP') $auto_charset = 'euc-jp';
+         $sq_string_func_auto_charset = $default_charset;
+         if ($squirrelmail_language == 'ja_JP') $sq_string_func_auto_charset = 'euc-jp';
       }
-      $charset = $auto_charset;
+      $charset = $sq_string_func_auto_charset;
    }
 
 
@@ -1172,21 +1173,27 @@
  * @since 1.5.1 and 1.4.6
  */
 function sq_mb_list_encodings() {
+
+    // if it's already in the session, don't need to regenerate it
+    if (sqgetGlobalVar('mb_supported_encodings',$mb_supported_encodings,SQ_SESSION)
+     && is_array($mb_supported_encodings))
+        return $mb_supported_encodings;
+
     // check if mbstring extension is present
-    if (! function_exists('mb_internal_encoding'))
-        return array();
+    if (! function_exists('mb_internal_encoding')) {
+        $supported_encodings = array();
+        sqsession_register($supported_encodings, 'mb_supported_encodings');
+        return $supported_encodings;
+    }
 
     // php 5+ function
     if (function_exists('mb_list_encodings')) {
-        $ret = mb_list_encodings();
-        array_walk($ret,'sq_lowercase_array_vals');
-        return $ret;
+        $supported_encodings = mb_list_encodings();
+        array_walk($supported_encodings, 'sq_lowercase_array_vals');
+        sqsession_register($supported_encodings, 'mb_supported_encodings');
+        return $supported_encodings;
     }
 
-    // don't try to test encodings, if they are already stored in session
-    if (sqgetGlobalVar('mb_supported_encodings',$mb_supported_encodings,SQ_SESSION))
-        return $mb_supported_encodings;
-
     // save original encoding
     $orig_encoding=mb_internal_encoding();
 
@@ -1231,7 +1238,7 @@
     mb_internal_encoding($orig_encoding);
 
     // register list in session
-    sqsession_register($supported_encodings,'mb_supported_encodings');
+    sqsession_register($supported_encodings, 'mb_supported_encodings');
 
     return $supported_encodings;
 }
@@ -1265,7 +1272,7 @@
   *                           list ("old" is 30 days or
   *                           older unless the administrator
   *                           overrides that value using
-  *                           $max_security_token_age in
+  *                           $max_token_age_days in
   *                           config/config_local.php)
   *                           (OPTIONAL; default is to always
   *                           purge old tokens)
@@ -1357,7 +1364,7 @@
   * is too old but otherwise valid, it will still be rejected.
   *
   * "Too old" is 30 days or older unless the administrator
-  * overrides that value using $max_security_token_age in
+  * overrides that value using $max_token_age_days in
   * config/config_local.php
   *
   * WARNING: If the administrator has turned the token system
