mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-05 19:04:27 +02:00
Update for {fetch} plugin
This commit is contained in:
@@ -20,7 +20,7 @@ class PluginFunctionFetchTest extends PHPUnit_Smarty
|
|||||||
$this->setUpSmarty(dirname(__FILE__));
|
$this->setUpSmarty(dirname(__FILE__));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testInit()
|
public function testInit()
|
||||||
{
|
{
|
||||||
$this->cleanDirs();
|
$this->cleanDirs();
|
||||||
}
|
}
|
||||||
@@ -46,22 +46,23 @@ class PluginFunctionFetchTest extends PHPUnit_Smarty
|
|||||||
* @preserveGlobalState disabled
|
* @preserveGlobalState disabled
|
||||||
*/
|
*/
|
||||||
public function testFetchInvalidUri()
|
public function testFetchInvalidUri()
|
||||||
{
|
{
|
||||||
$result = $this->smarty->fetch('string:{fetch file="https://foo.smarty.net/foo.dat"}');
|
$result = $this->smarty->fetch('string:{fetch file="https://foo.smarty.net/foo.dat"}');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* test {fetch file=...} access to file from path not aloowed by security settings
|
* test {fetch file=...} access to file from path not aloo/wed by security settings
|
||||||
*
|
*
|
||||||
* @expectedException SmartyException
|
* @expectedException SmartyException
|
||||||
* @expectedExceptionMessage not allowed by security setting
|
* @expectedExceptionMessage not trusted file pat
|
||||||
* @run InSeparateProcess
|
* @run InSeparateProcess
|
||||||
* @preserveGlobalState disabled
|
* @preserveGlobalState disabled
|
||||||
*/
|
*/
|
||||||
public function testFetchSecurity()
|
public function testFetchSecurity()
|
||||||
{
|
{
|
||||||
$dir=$this->smarty->getTemplateDir();
|
$this->cleanDirs();
|
||||||
$this->smarty->enableSecurity();
|
$dir=$this->smarty->getTemplateDir();
|
||||||
$result = $this->smarty->fetch('string:{fetch file=\''. $dir[0]. '..\..\..\..\..\etc\passwd\'}');
|
$this->smarty->enableSecurity();
|
||||||
}
|
$result = $this->smarty->fetch('string:{fetch file=\''. $dir[0]. '../../../../../etc/passwd\'}');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user