Преглед на файлове

fix mbstring overloading issue with passwords (#929644).

tokul преди 20 години
родител
ревизия
ffb669bcac
променени са 2 файла, в които са добавени 23 реда и са изтрити 0 реда
  1. 2 0
      ChangeLog
  2. 21 0
      functions/i18n.php

+ 2 - 0
ChangeLog

@@ -287,6 +287,8 @@ Version 1.5.1 -- CVS
     initialization.
     initialization.
   - Fixed wrapping of multibyte strings in message view and replies 
   - Fixed wrapping of multibyte strings in message view and replies 
     (#1043576).
     (#1043576).
+  - mbstring internal encoding is switched to ASCII, if mbstring.func_overload
+    is enabled (#929644).
   
   
 Version 1.5.0
 Version 1.5.0
 --------------------
 --------------------

+ 21 - 0
functions/i18n.php

@@ -413,6 +413,27 @@ function set_up_language($sm_language, $do_search = false, $default = false) {
         } else {
         } else {
             header( 'Content-Type: text/html; charset=' . $languages[$sm_notAlias]['CHARSET'] );
             header( 'Content-Type: text/html; charset=' . $languages[$sm_notAlias]['CHARSET'] );
         }
         }
+
+        /**
+         * mbstring.func_overload fix (#929644).
+         *
+         * php mbstring extension can replace standard string functions with their multibyte 
+         * equivalents. See http://www.php.net/ref.mbstring#mbstring.overload.
+         *
+         * Some SquirrelMail functions work with 8bit strings in bytes. If interface is forced
+         * to use mbstring functions and mbstring internal encoding is set to multibyte charset,
+         * interface can't trust regular string functions. Due to mbstring overloading design 
+         * limits php scripts can't control this setting.
+         *
+         * This hack should fix some issues related to 8bit strings in passwords. Correct fix is
+         * to disable mbstring overloading. Japanese translation uses different internal encoding.
+         */
+        if ($squirrelmail_language != 'ja_JP' && 
+            function_exists('mb_internal_encoding') &&
+            check_php_version(4,2,0) &&
+            (int)ini_get('mbstring.func_overload')!=0) {
+            mb_internal_encoding('ASCII');
+        }
     }
     }
     return 0;
     return 0;
 }
 }