mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-16 04:16:28 +00:00
made some tweak to the security check for the filesystem loader
This commit is contained in:
@@ -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'),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user