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.
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;
}
}