Commit 57022c2d by Seldaek

* Include allows paths going in upper levels now such as : "../foo.html"

git-svn-id: svn://dwoo.org/dwoo/trunk@123 0598d79b-80c4-4d41-97ba-ac86fbbd088b
parent e3eb1b76
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
=> http://forum.dwoo.org/viewtopic.php?id=50 => http://forum.dwoo.org/viewtopic.php?id=50
* Compiler now allows the use of the right delimiter inside strings (e.g. {"}"}) * Compiler now allows the use of the right delimiter inside strings (e.g. {"}"})
* Fixed a bug preventing if blocks containing a {elseif} followed by {else} * Fixed a bug preventing if blocks containing a {elseif} followed by {else}
* Include allows paths going in upper levels now such as : "../foo.html"
[2008-06-28] 0.9.2 [2008-06-28] 0.9.2
! BC Break: Renamed the {strip} modifier/function to {whitespace}, this does ! BC Break: Renamed the {strip} modifier/function to {whitespace}, this does
......
...@@ -59,6 +59,10 @@ function Dwoo_Plugin_include(Dwoo $dwoo, $file, $cache_time = null, $cache_id = ...@@ -59,6 +59,10 @@ function Dwoo_Plugin_include(Dwoo $dwoo, $file, $cache_time = null, $cache_id =
} }
} }
if ($resource === 'file' && strpos($identifier, '..') !== false) {
$identifier = realpath(dirname($dwoo->getTemplate()->getResourceIdentifier()) . DIRECTORY_SEPARATOR . $identifier);
}
try { try {
$include = $dwoo->templateFactory($resource, $identifier, $cache_time, $cache_id, $compile_id); $include = $dwoo->templateFactory($resource, $identifier, $cache_time, $cache_id, $compile_id);
} catch (Dwoo_Exception $e) { } catch (Dwoo_Exception $e) {
......
...@@ -243,6 +243,14 @@ class FuncTests extends PHPUnit_Framework_TestCase ...@@ -243,6 +243,14 @@ class FuncTests extends PHPUnit_Framework_TestCase
$this->assertEquals("34", $this->dwoo->get($tpl, array(), $this->compiler)); $this->assertEquals("34", $this->dwoo->get($tpl, array(), $this->compiler));
} }
public function testIncludeParent()
{
$tpl = new Dwoo_Template_File(TEST_DIRECTORY.'/resources/subfolder/inctest.html');
$tpl->forceCompilation();
$this->assertEquals("43", $this->dwoo->get($tpl, array(), $this->compiler));
}
public function testIndent() public function testIndent()
{ {
$tpl = new Dwoo_Template_String('{indent $foo 6 "-"}'); $tpl = new Dwoo_Template_String('{indent $foo 6 "-"}');
......
{include file="../test.html" foo=4 bar=3}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment