From: nirgal Date: Fri, 4 Oct 2019 08:58:02 +0000 (+0000) Subject: Support truncation of mulitbyte srings X-Git-Tag: REL_7-12-1~12 X-Git-Url: http://git.postgresql.org/gitweb/?a=commitdiff_plain;h=b24f5cae385137eddc487204a4c7a864de3d032b;p=phppgadmin.git Support truncation of mulitbyte srings This fixes https://sourceforge.net/p/phppgadmin/bugs/422/ : substr truncates on a byte-level, sometimes within a multi-byte character. This resulted in the whole string sometime not being displayed. See the original bug report for a way to reproduce. Please note that this requires php-mbstring to be installed. This is usually the case, but the dependency should be described in the INSTALL file or something. --- diff --git a/classes/Misc.php b/classes/Misc.php index 87a5eb6f..9939502e 100644 --- a/classes/Misc.php +++ b/classes/Misc.php @@ -261,8 +261,8 @@ if (isset($params['clip']) && $params['clip'] === true) { $maxlen = isset($params['cliplen']) && is_integer($params['cliplen']) ? $params['cliplen'] : $conf['max_chars']; $ellipsis = isset($params['ellipsis']) ? $params['ellipsis'] : $lang['strellipsis']; - if (strlen($str) > $maxlen) { - $str = substr($str, 0, $maxlen-1) . $ellipsis; + if (mb_strlen($str, 'UTF-8') > $maxlen) { + $str = mb_substr($str, 0, $maxlen-1, 'UTF-8') . $ellipsis; } }