made some tweak to the security check for the filesystem loader

This commit is contained in:
Fabien Potencier
2010-12-14 17:24:03 +01:00
parent a349b24306
commit 9e5b2becf4
2 changed files with 7 additions and 1 deletions
+1 -1
View File
@@ -102,7 +102,7 @@ class Twig_Loader_Filesystem implements Twig_LoaderInterface
protected function findTemplate($name)
{
// normalize name
$name = str_replace('\\', '/', $name);
$name = preg_replace('#(/+|\\+)#', '/', str_replace('\\', '/', $name));
$parts = explode('/', $name);
$level = 0;
@@ -25,7 +25,9 @@ class Twig_Tests_Loader_FilesystemTest extends PHPUnit_Framework_TestCase
{
return array(
array('..\\AutoloaderTest.php'),
array('..\\\\\\AutoloaderTest.php'),
array('../AutoloaderTest.php'),
array('..////AutoloaderTest.php'),
array('./../AutoloaderTest.php'),
array('.\\..\\AutoloaderTest.php'),
array('././././././../AutoloaderTest.php'),
@@ -35,6 +37,10 @@ class Twig_Tests_Loader_FilesystemTest extends PHPUnit_Framework_TestCase
array('foo/../bar/../../AutoloaderTest.php'),
array('foo/bar/../../../AutoloaderTest.php'),
array('filters/../../AutoloaderTest.php'),
array('filters//..//..//AutoloaderTest.php'),
array('filters\\..\\..\\AutoloaderTest.php'),
array('filters\\\\..\\\\..\\\\AutoloaderTest.php'),
array('filters\\//../\\/\\..\\AutoloaderTest.php'),
);
}
}