📌 N°4284 Composer libs : fix twig/twig to ~1.42.5

Without specifying explicitly the Twig version, since the update of require php from 5.6 to 7.0 we are getting Twig 2.12.5 !
We don't want Twig 2 as this version changes the macro scope and causes massive changes in our code... This update will be done later in other branches.
This commit is contained in:
Pierre Goiffon
2022-04-29 11:58:11 +02:00
parent d0ba0d193b
commit 64b25c4daa
27 changed files with 230 additions and 86 deletions

View File

@@ -1,3 +1,7 @@
* 1.42.5 (2020-02-11)
* Fix implementation of case-insensitivity for method names
* 1.42.4 (2019-11-11)
* optimized "block('foo') ?? 'bar"

View File

@@ -1,6 +1,4 @@
Copyright (c) 2009-2019 by the Twig Team.
Some rights reserved.
Copyright (c) 2009-2020 by the Twig Team.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are

View File

@@ -14,7 +14,6 @@
},
{
"name": "Twig Team",
"homepage": "https://twig.symfony.com/contributors",
"role": "Contributors"
},
{
@@ -28,8 +27,7 @@
"symfony/polyfill-ctype": "^1.8"
},
"require-dev": {
"symfony/phpunit-bridge": "^4.4@dev|^5.0",
"symfony/debug": "^3.4|^4.2",
"symfony/phpunit-bridge": "^4.4|^5.0",
"psr/container": "^1.0"
},
"autoload": {

View File

@@ -15,7 +15,7 @@
#ifndef PHP_TWIG_H
#define PHP_TWIG_H
#define PHP_TWIG_VERSION "1.42.4"
#define PHP_TWIG_VERSION "1.42.5-DEV"
#include "php.h"

View File

@@ -41,11 +41,11 @@ use Twig\TokenParser\TokenParserInterface;
*/
class Environment
{
const VERSION = '1.42.4';
const VERSION_ID = 14204;
const VERSION = '1.42.5';
const VERSION_ID = 14205;
const MAJOR_VERSION = 1;
const MINOR_VERSION = 42;
const RELEASE_VERSION = 4;
const RELEASE_VERSION = 5;
const EXTRA_VERSION = '';
protected $charset;

View File

@@ -657,7 +657,7 @@ class ExpressionParser
$stream->expect(Token::NAME_TYPE, 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());

View File

@@ -459,7 +459,7 @@ function twig_date_modify_filter(Environment $env, $date, $modifier)
* @param \DateTime|\DateTimeInterface|string|null $date A date
* @param \DateTimeZone|string|false|null $timezone The target timezone, null to use the default, false to leave unchanged
*
* @return \DateTime
* @return \DateTimeInterface
*/
function twig_date_converter(Environment $env, $date = null, $timezone = null)
{

View File

@@ -299,7 +299,7 @@ class Parser implements \Twig_ParserInterface
$this->reservedMacroNames = [];
$r = new \ReflectionClass($this->env->getBaseTemplateClass());
foreach ($r->getMethods() as $method) {
$methodName = strtolower($method->getName());
$methodName = strtr($method->getName(), 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz');
if ('get' === substr($methodName, 0, 3) && isset($methodName[3])) {
$this->reservedMacroNames[] = substr($methodName, 3);
@@ -307,7 +307,7 @@ class Parser implements \Twig_ParserInterface
}
}
return \in_array(strtolower($name), $this->reservedMacroNames);
return \in_array(strtr($name, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz'), $this->reservedMacroNames);
}
public function addTrait($trait)

View File

@@ -51,7 +51,7 @@ 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]);
}
}
@@ -93,7 +93,7 @@ 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);

View File

@@ -628,7 +628,7 @@ abstract class Template implements \Twig_TemplateInterface
foreach ($ref->getMethods(\ReflectionMethod::IS_PUBLIC) as $refMethod) {
// Accessing the environment from templates is forbidden to prevent untrusted changes to the environment
if ('getenvironment' !== strtolower($refMethod->name)) {
if ('getenvironment' !== strtr($refMethod->name, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz')) {
$methods[] = $refMethod->name;
}
}
@@ -642,7 +642,7 @@ abstract class Template implements \Twig_TemplateInterface
foreach ($methods as $method) {
$cache[$method] = $method;
$cache[$lcName = strtolower($method)] = $method;
$cache[$lcName = strtr($method, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz')] = $method;
if ('g' === $lcName[0] && 0 === strpos($lcName, 'get')) {
$name = substr($method, 3);
@@ -670,7 +670,7 @@ abstract class Template implements \Twig_TemplateInterface
$call = false;
if (isset(self::$cache[$class][$item])) {
$method = self::$cache[$class][$item];
} elseif (isset(self::$cache[$class][$lcItem = strtolower($item)])) {
} elseif (isset(self::$cache[$class][$lcItem = strtr($item, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz')])) {
$method = self::$cache[$class][$lcItem];
} elseif (isset(self::$cache[$class]['__call'])) {
$method = $item;