From f5c507dc3370b82ce00996914c85c4230da4b321 Mon Sep 17 00:00:00 2001 From: tokul Date: Tue, 29 Mar 2005 09:14:06 +0000 Subject: [PATCH] fix mbstring overloading issue with passwords (#929644). git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@9151 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- ChangeLog | 2 ++ functions/i18n.php | 21 +++++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/ChangeLog b/ChangeLog index d1216732..af4c086f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -287,6 +287,8 @@ Version 1.5.1 -- CVS initialization. - Fixed wrapping of multibyte strings in message view and replies (#1043576). + - mbstring internal encoding is switched to ASCII, if mbstring.func_overload + is enabled (#929644). Version 1.5.0 -------------------- diff --git a/functions/i18n.php b/functions/i18n.php index 7b0c3813..8c53b590 100644 --- a/functions/i18n.php +++ b/functions/i18n.php @@ -413,6 +413,27 @@ function set_up_language($sm_language, $do_search = false, $default = false) { } else { 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; } -- 2.25.1