diff --git a/src/ExpressionParser.php b/src/ExpressionParser.php index 4304af8bf..6784ebfd1 100644 --- a/src/ExpressionParser.php +++ b/src/ExpressionParser.php @@ -638,7 +638,7 @@ class ExpressionParser $stream->expect(/* Token::NAME_TYPE */ 5, null, 'Only variables can be assigned to'); } $value = $token->getValue(); - if (\in_array(strtolower($value), ['true', 'false', 'none', 'null'])) { + if (\in_array(strtr($value, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz'), ['true', 'false', 'none', 'null'])) { throw new SyntaxError(sprintf('You cannot assign a value to "%s".', $value), $token->getLine(), $stream->getSourceContext()); } $targets[] = new AssignNameExpression($value, $token->getLine()); diff --git a/src/Extension/CoreExtension.php b/src/Extension/CoreExtension.php index 3f62547d2..bbb55596b 100644 --- a/src/Extension/CoreExtension.php +++ b/src/Extension/CoreExtension.php @@ -1457,7 +1457,7 @@ function twig_get_attribute(Environment $env, Source $source, $object, $item, ar if (!isset($cache[$class])) { $methods = get_class_methods($object); sort($methods); - $lcMethods = array_map('strtolower', $methods); + $lcMethods = array_map(function ($value) { return strtr($value, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz'); }, $methods); $classCache = []; foreach ($methods as $i => $method) { $classCache[$method] = $method; @@ -1496,7 +1496,7 @@ function twig_get_attribute(Environment $env, Source $source, $object, $item, ar $call = false; if (isset($cache[$class][$item])) { $method = $cache[$class][$item]; - } elseif (isset($cache[$class][$lcItem = strtolower($item)])) { + } elseif (isset($cache[$class][$lcItem = strtr($item, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz')])) { $method = $cache[$class][$lcItem]; } elseif (isset($cache[$class]['__call'])) { $method = $item; diff --git a/src/Sandbox/SecurityPolicy.php b/src/Sandbox/SecurityPolicy.php index ca7c30738..2fc0d0131 100644 --- a/src/Sandbox/SecurityPolicy.php +++ b/src/Sandbox/SecurityPolicy.php @@ -50,7 +50,7 @@ final class SecurityPolicy implements SecurityPolicyInterface { $this->allowedMethods = []; foreach ($methods as $class => $m) { - $this->allowedMethods[$class] = array_map('strtolower', \is_array($m) ? $m : [$m]); + $this->allowedMethods[$class] = array_map(function ($value) { return strtr($value, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz'); }, \is_array($m) ? $m : [$m]); } } @@ -92,7 +92,7 @@ final class SecurityPolicy implements SecurityPolicyInterface } $allowed = false; - $method = strtolower($method); + $method = strtr($method, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz'); foreach ($this->allowedMethods as $class => $methods) { if ($obj instanceof $class) { $allowed = \in_array($method, $methods);