mirror of
https://github.com/wintercms/winter.git
synced 2024-06-28 05:33:29 +02:00
Only allow view files in system twig
This no longer allows arbitrary inclusions, only views from the native Laravel view engine. Note this also affects the cms twig loader
This commit is contained in:
parent
d4ac1595ad
commit
f9e14b02f5
@ -2,6 +2,7 @@
|
||||
|
||||
use App;
|
||||
use File;
|
||||
use View;
|
||||
use Twig\Source as TwigSource;
|
||||
use Twig\Loader\LoaderInterface as TwigLoaderInterface;
|
||||
use Exception;
|
||||
@ -14,11 +15,6 @@ use Exception;
|
||||
*/
|
||||
class Loader implements TwigLoaderInterface
|
||||
{
|
||||
/**
|
||||
* @var string Expected file extension
|
||||
*/
|
||||
protected $extension = 'htm';
|
||||
|
||||
/**
|
||||
* @var array Cache
|
||||
*/
|
||||
@ -37,22 +33,13 @@ class Loader implements TwigLoaderInterface
|
||||
return $this->cache[$name];
|
||||
}
|
||||
|
||||
if (File::isFile($name)) {
|
||||
return $this->cache[$name] = $name;
|
||||
}
|
||||
|
||||
$view = $name;
|
||||
if (File::extension($view) === $this->extension) {
|
||||
$view = substr($view, 0, -strlen($this->extension));
|
||||
}
|
||||
|
||||
$path = $finder->find($view);
|
||||
$path = $finder->find($name);
|
||||
return $this->cache[$name] = $path;
|
||||
}
|
||||
|
||||
public function getSourceContext($name)
|
||||
{
|
||||
return new TwigSource(File::get($this->findTemplate($name)), $name);
|
||||
return new TwigSource((string) View::make($name), $name);
|
||||
}
|
||||
|
||||
public function getCacheKey($name)
|
||||
|
Loading…
x
Reference in New Issue
Block a user