- update {include_php} with new realpath handling

This commit is contained in:
Uwe Tews
2015-06-27 20:25:54 +02:00
parent f567d5d778
commit 75ccd86c8a
2 changed files with 8 additions and 5 deletions

View File

@@ -3,7 +3,8 @@
- bugfix resolve naming conflict between custom Smarty delimiter '<%' and PHP ASP tags https://github.com/smarty-php/smarty/issues/64 - bugfix resolve naming conflict between custom Smarty delimiter '<%' and PHP ASP tags https://github.com/smarty-php/smarty/issues/64
- update $smarty->_realpath for relative path not starting with './' - update $smarty->_realpath for relative path not starting with './'
- update Smarty security with new realpath handling - update Smarty security with new realpath handling
- update {include_php} with new realpath handling
19.06.2015 19.06.2015
- improvement allow closures as callback at $smarty->registerFilter() https://github.com/smarty-php/smarty/issues/59 - improvement allow closures as callback at $smarty->registerFilter() https://github.com/smarty-php/smarty/issues/59

View File

@@ -23,6 +23,7 @@ class Smarty_Internal_Compile_Include_Php extends Smarty_Internal_CompileBase
* @see Smarty_Internal_CompileBase * @see Smarty_Internal_CompileBase
*/ */
public $required_attributes = array('file'); public $required_attributes = array('file');
/** /**
* Attribute definition: Overwrites base class. * Attribute definition: Overwrites base class.
* *
@@ -30,6 +31,7 @@ class Smarty_Internal_Compile_Include_Php extends Smarty_Internal_CompileBase
* @see Smarty_Internal_CompileBase * @see Smarty_Internal_CompileBase
*/ */
public $shorttag_order = array('file'); public $shorttag_order = array('file');
/** /**
* Attribute definition: Overwrites base class. * Attribute definition: Overwrites base class.
* *
@@ -62,7 +64,7 @@ class Smarty_Internal_Compile_Include_Php extends Smarty_Internal_CompileBase
$_filepath = false; $_filepath = false;
eval('$_file = ' . $_attr['file'] . ';'); eval('$_file = ' . $_attr['file'] . ';');
if (!isset($compiler->smarty->security_policy) && file_exists($_file)) { if (!isset($compiler->smarty->security_policy) && file_exists($_file)) {
$_filepath = $_file; $_filepath = $compiler->smarty->_realpath($_file);
} else { } else {
if (isset($compiler->smarty->security_policy)) { if (isset($compiler->smarty->security_policy)) {
$_dir = $compiler->smarty->security_policy->trusted_dir; $_dir = $compiler->smarty->security_policy->trusted_dir;
@@ -71,9 +73,9 @@ class Smarty_Internal_Compile_Include_Php extends Smarty_Internal_CompileBase
} }
if (!empty($_dir)) { if (!empty($_dir)) {
foreach ((array) $_dir as $_script_dir) { foreach ((array) $_dir as $_script_dir) {
$_script_dir = rtrim($_script_dir, '/\\') . DS; $_path = $compiler->smarty->_realpath($_script_dir . DS . $_file);
if (file_exists($_script_dir . $_file)) { if (file_exists($_path)) {
$_filepath = $_script_dir . $_file; $_filepath = $_path;
break; break;
} }
} }