From e59c443aa8f40c21ca9742b913dc72de7915be3c Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 5 Aug 2013 09:09:11 +0200 Subject: [PATCH] fixed filesystem loader when the name needs to be normalized --- lib/Twig/Loader/Filesystem.php | 11 ++++++++--- 1 files changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/Twig/Loader/Filesystem.php b/lib/Twig/Loader/Filesystem.php index 5073b5e..ffa40a3 100644 --- a/lib/Twig/Loader/Filesystem.php +++ b/lib/Twig/Loader/Filesystem.php @@ -144,7 +144,7 @@ class Twig_Loader_Filesystem implements Twig_LoaderInterface, Twig_ExistsLoaderI */ public function exists($name) { - return $this->doFindTemplate($name); + return $this->doFindTemplate($this->normalizeName($name)); } /** @@ -157,6 +157,8 @@ class Twig_Loader_Filesystem implements Twig_LoaderInterface, Twig_ExistsLoaderI protected function findTemplate($name) { + $name = $this->normalizeName($name); + if ($this->doFindTemplate($name)) { return $this->cache[$name]; } @@ -166,8 +168,6 @@ class Twig_Loader_Filesystem implements Twig_LoaderInterface, Twig_ExistsLoaderI protected function doFindTemplate($name) { - $name = preg_replace('#/{2,}#', '/', strtr((string) $name, '\\', '/')); - $this->validateName($name); if (isset($this->cache[$name])) { @@ -210,6 +210,11 @@ class Twig_Loader_Filesystem implements Twig_LoaderInterface, Twig_ExistsLoaderI return false; } + protected function normalizeName($name) + { + return preg_replace('#/{2,}#', '/', strtr((string) $name, '\\', '/')); + } + protected function validateName($name) { if (false !== strpos($name, "\0")) { -- 1.7.2.5