phpBB

Code Changes

File: phpbb/template/twig/loader.php

  Unmodified   Added   Modified   Removed
Line 19Line 19
class loader extends \Twig_Loader_Filesystem
{
protected $safe_directories = array();

class loader extends \Twig_Loader_Filesystem
{
protected $safe_directories = array();

 

/**
* @var \phpbb\filesystem\filesystem_interface
*/
protected $filesystem;

/**
* Constructor
*
* @param \phpbb\filesystem\filesystem_interface $filesystem
* @param string|array $paths
*/
public function __construct(\phpbb\filesystem\filesystem_interface $filesystem, $paths = array())
{
$this->filesystem = $filesystem;

parent::__construct($paths);
}


/**
* Set safe directories


/**
* Set safe directories

Line 49Line 67
	*/
public function addSafeDirectory($directory)
{

	*/
public function addSafeDirectory($directory)
{

		$directory = phpbb_realpath($directory);

		$directory = $this->filesystem->realpath($directory);


if ($directory !== false)
{


if ($directory !== false)
{

Line 80Line 98
	protected function validateName($name)
{
return;

	protected function validateName($name)
{
return;

 
	}

/**
* Adds a realpath call to fix a BC break in Twig 1.26 (https://github.com/twigphp/Twig/issues/2145)
*
* {@inheritdoc}
*/
public function addPath($path, $namespace = self::MAIN_NAMESPACE)
{
return parent::addPath($this->filesystem->realpath($path), $namespace);

	}

/**

	}

/**

Line 97Line 125

// If this is in the cache we can skip the entire process below
// as it should have already been validated


// If this is in the cache we can skip the entire process below
// as it should have already been validated

		if (isset($this->cache[$name])) {


		if (isset($this->cache[$name]))
{

			return $this->cache[$name];
}


			return $this->cache[$name];
}


Line 118Line 147
				//	can now check if we're within a "safe" directory

// Find the real path of the directory the file is in

				//	can now check if we're within a "safe" directory

// Find the real path of the directory the file is in

				$directory = phpbb_realpath(dirname($file));

				$directory = $this->filesystem->realpath(dirname($file));


if ($directory === false)
{


if ($directory === false)
{