diff --git a/modules/system/twig/Engine.php b/modules/system/twig/Engine.php index affcab34e..6a3cbcae3 100644 --- a/modules/system/twig/Engine.php +++ b/modules/system/twig/Engine.php @@ -1,5 +1,6 @@ environment->loadTemplate($path); + + TwigLoader::$allowInclude = $previousAllow; + return $template->render($vars); } } diff --git a/modules/system/twig/Loader.php b/modules/system/twig/Loader.php index c42756a0a..baafc7773 100644 --- a/modules/system/twig/Loader.php +++ b/modules/system/twig/Loader.php @@ -15,9 +15,9 @@ use Exception; class Loader implements TwigLoaderInterface { /** - * @var string Expected file extension + * @var bool Allow any local file */ - protected $extension = 'htm'; + public static $allowInclude = false; /** * @var array Cache @@ -37,9 +37,8 @@ class Loader implements TwigLoaderInterface return $this->cache[$name]; } - $view = $name; - if (File::extension($view) === $this->extension) { - $view = substr($view, 0, -strlen($this->extension)); + if (static::$allowInclude === true && File::isFile($name)) { + return $this->cache[$name] = $name; } $path = $finder->find($name);