pico/lib/twig/test/Twig/Tests/Loader/FilesystemTest.php
Gilbert Pellegrom 92b792e8f2 Initial commit.
2012-04-04 14:45:09 +01:00

53 lines
1.7 KiB
PHP
Executable File

<?php
/*
* This file is part of Twig.
*
* (c) Fabien Potencier
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
class Twig_Tests_Loader_FilesystemTest extends PHPUnit_Framework_TestCase
{
/**
* @dataProvider getSecurityTests
*/
public function testSecurity($template)
{
$loader = new Twig_Loader_Filesystem(array(dirname(__FILE__).'/../Fixtures'));
try {
$loader->getCacheKey($template);
$this->fail();
} catch (Twig_Error_Loader $e) {
$this->assertNotContains('Unable to find template', $e->getMessage());
}
}
public function getSecurityTests()
{
return array(
array("AutoloaderTest\0.php"),
array('..\\AutoloaderTest.php'),
array('..\\\\\\AutoloaderTest.php'),
array('../AutoloaderTest.php'),
array('..////AutoloaderTest.php'),
array('./../AutoloaderTest.php'),
array('.\\..\\AutoloaderTest.php'),
array('././././././../AutoloaderTest.php'),
array('.\\./.\\./.\\./../AutoloaderTest.php'),
array('foo/../../AutoloaderTest.php'),
array('foo\\..\\..\\AutoloaderTest.php'),
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'),
);
}
}