summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornirgal2019-10-04 08:58:02 +0000
committerRobert Treat2019-10-13 00:27:23 +0000
commitb24f5cae385137eddc487204a4c7a864de3d032b (patch)
tree806cc5eb35fbe21f9cf9acca2ccbf57e81b1fde2
parent1d5ca056572e93c5509f5052c39e080f07fadd9e (diff)
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.
-rw-r--r--classes/Misc.php4
1 files changed, 2 insertions, 2 deletions
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;
}
}