diff options
| author | Nathan Guse <nathaniel.guse@gmail.com> | 2013-09-02 11:25:36 -0500 |
|---|---|---|
| committer | Nathan Guse <nathaniel.guse@gmail.com> | 2013-09-02 12:13:20 -0500 |
| commit | 5e86f5687b30397c0e520fd32a9fc92b7e155a16 (patch) | |
| tree | c0376dd3424d39d1572768d592a18ada0d293700 /phpBB/phpbb/template/twig/twig.php | |
| parent | 9d6370751f1b998e3da448e16c1446b33ddd17d0 (diff) | |
| download | forums-5e86f5687b30397c0e520fd32a9fc92b7e155a16.tar forums-5e86f5687b30397c0e520fd32a9fc92b7e155a16.tar.gz forums-5e86f5687b30397c0e520fd32a9fc92b7e155a16.tar.bz2 forums-5e86f5687b30397c0e520fd32a9fc92b7e155a16.tar.xz forums-5e86f5687b30397c0e520fd32a9fc92b7e155a16.zip | |
[ticket/11727] Template loader support for safe directories to load files from
PHPBB3-11727
Diffstat (limited to 'phpBB/phpbb/template/twig/twig.php')
| -rw-r--r-- | phpBB/phpbb/template/twig/twig.php | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/phpBB/phpbb/template/twig/twig.php b/phpBB/phpbb/template/twig/twig.php index 1ed89d3ccc..5746cc64a3 100644 --- a/phpBB/phpbb/template/twig/twig.php +++ b/phpBB/phpbb/template/twig/twig.php @@ -91,7 +91,7 @@ class phpbb_template_twig extends phpbb_template_base $this->cachepath = $phpbb_root_path . 'cache/twig/'; // Initiate the loader, __main__ namespace paths will be setup later in set_style_names() - $loader = new Twig_Loader_Filesystem(''); + $loader = new phpbb_template_twig_loader(''); $this->twig = new phpbb_template_twig_environment( $this->config, @@ -181,11 +181,15 @@ class phpbb_template_twig extends phpbb_template_base { foreach ($names as $name) { - $path = $this->phpbb_root_path . trim($directory, '/') . "/{$name}/template/"; + $path = $this->phpbb_root_path . trim($directory, '/') . "/{$name}/"; + $template_path = $path . 'template/'; - if (is_dir($path)) + if (is_dir($template_path)) { - $paths[] = $path; + // Add the base style directory as a safe directory + $this->twig->getLoader()->addSafeDirectory($path); + + $paths[] = $template_path; } } } @@ -233,11 +237,15 @@ class phpbb_template_twig extends phpbb_template_base foreach ($names as $style_name) { - $ext_style_path = $ext_path . 'styles/' . $style_name . '/template'; + $ext_style_path = $ext_path . 'styles/' . $style_name . '/'; + $ext_style_template_path = $ext_style_path . 'template/'; - if (is_dir($ext_style_path)) + if (is_dir($ext_style_template_path)) { - $paths[] = $ext_style_path; + // Add the base style directory as a safe directory + $this->twig->getLoader()->addSafeDirectory($ext_style_path); + + $paths[] = $ext_style_template_path; } } |
