From 74bc298d20e475409dc28a7b66e3c6beae5779cc Mon Sep 17 00:00:00 2001 From: Hugues Peccatte Date: Tue, 30 Sep 2014 21:50:07 +0200 Subject: [PATCH] Improve mb_substr using native substr. Signed-off-by: Hugues Peccatte --- libraries/stringNative.lib.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/libraries/stringNative.lib.php b/libraries/stringNative.lib.php index a77bf1e9c2..6af2c12b33 100644 --- a/libraries/stringNative.lib.php +++ b/libraries/stringNative.lib.php @@ -35,6 +35,12 @@ if (!@function_exists('mb_strlen')) { */ function mb_substr($string, $start, $length = 2147483647) { + if (null === $string || strlen($string) <= $start) { + return ''; + } + if (null === $length) { + $length = 2147483647; + } return substr($string, $start, $length); }