move check for template_dir in secure_dir-array into core.is_secure.php

this makes template_exists() work correctly with security=true even if
template_dir is not inside the secure_dir-array
This commit is contained in:
messju
2003-10-12 22:19:32 +00:00
parent de3ef126bf
commit 9b3ca8956e
2 changed files with 8 additions and 5 deletions

View File

@@ -1170,11 +1170,6 @@ class Smarty
$_smarty_old_error_level = $this->debugging ? error_reporting() : error_reporting(error_reporting() & ~E_NOTICE); $_smarty_old_error_level = $this->debugging ? error_reporting() : error_reporting(error_reporting() & ~E_NOTICE);
if($this->security && !in_array($this->template_dir, $this->secure_dir)) {
// add template_dir to secure_dir array
array_unshift($this->secure_dir, $this->template_dir);
}
if (!$this->debugging && $this->debugging_ctrl == 'URL' if (!$this->debugging && $this->debugging_ctrl == 'URL'
&& @strstr($GLOBALS['HTTP_SERVER_VARS']['QUERY_STRING'], $this->_smarty_debug_id)) { && @strstr($GLOBALS['HTTP_SERVER_VARS']['QUERY_STRING'], $this->_smarty_debug_id)) {
// enable debugging from URL // enable debugging from URL

View File

@@ -17,12 +17,20 @@
function smarty_core_is_secure($params, &$smarty) function smarty_core_is_secure($params, &$smarty)
{ {
static $check_template_dir = true;
if (!$smarty->security || $smarty->security_settings['INCLUDE_ANY']) { if (!$smarty->security || $smarty->security_settings['INCLUDE_ANY']) {
return true; return true;
} }
$_smarty_secure = false; $_smarty_secure = false;
if ($params['resource_type'] == 'file') { if ($params['resource_type'] == 'file') {
if($check_template_dir) {
if (!in_array($smarty->template_dir, $smarty->secure_dir))
// add template_dir to secure_dir array
array_unshift($smarty->secure_dir, $smarty->template_dir);
$check_template_dir = false;
}
if (!empty($smarty->secure_dir)) { if (!empty($smarty->secure_dir)) {
$_rp = realpath($params['resource_name']); $_rp = realpath($params['resource_name']);
foreach ((array)$smarty->secure_dir as $curr_dir) { foreach ((array)$smarty->secure_dir as $curr_dir) {