mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-12 02:16:41 +00:00
Fixed slice filter w/ null length for string values
This commit is contained in:
@@ -550,8 +550,16 @@ function twig_slice(Twig_Environment $env, $item, $start, $length = null)
|
||||
$item = (string) $item;
|
||||
|
||||
if (function_exists('mb_get_info') && null !== $charset = $env->getCharset()) {
|
||||
if (null === $length) {
|
||||
$length = mb_strlen($item, $charset) - $start;
|
||||
}
|
||||
|
||||
return mb_substr($item, $start, $length, $charset);
|
||||
}
|
||||
|
||||
if (null === $length) {
|
||||
return substr($item, $start);
|
||||
}
|
||||
|
||||
return substr($item, $start, $length);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user