- bugfix a filepath starting with '/' or '\' on windows should normalize to the root dir

of current working drive https://github.com/smarty-php/smarty/issues/134 (reverted from commit e29834387f)
This commit is contained in:
uwetews
2015-12-21 16:36:33 +01:00
parent e29834387f
commit 5a418efe57
2 changed files with 60 additions and 71 deletions

View File

@@ -1,8 +1,4 @@
 ===== 3.1.30-dev ===== (xx.xx.xx)
21.12.2015
- bugfix a filepath starting with '/' or '\' on windows should normalize to the root dir
of current working drive https://github.com/smarty-php/smarty/issues/134
===== 3.1.29 ===== (21.12.2015)
21.12.2015
- optimization improve speed of filetime checks on extends and extendsall resource

View File

@@ -118,7 +118,7 @@ class Smarty extends Smarty_Internal_TemplateBase
/**
* smarty version
*/
const SMARTY_VERSION = '3.1.30-dev/1';
const SMARTY_VERSION = '3.1.30-dev';
/**
* define variable scopes
@@ -1076,11 +1076,10 @@ class Smarty extends Smarty_Internal_TemplateBase
} else {
$data = null;
}
if ($this->caching && isset($this->_cache[ 'isCached' ][ $_templateId =
$this->_getTemplateId($template, $cache_id, $compile_id) ])
if ($this->caching &&
isset($this->_cache['isCached'][$_templateId = $this->_getTemplateId($template, $cache_id, $compile_id)])
) {
$tpl = $do_clone ? clone $this->_cache[ 'isCached' ][ $_templateId ] :
$this->_cache[ 'isCached' ][ $_templateId ];
$tpl = $do_clone ? clone $this->_cache['isCached'][$_templateId] : $this->_cache['isCached'][$_templateId];
$tpl->parent = $parent;
$tpl->tpl_vars = array();
$tpl->config_vars = array();
@@ -1160,9 +1159,7 @@ class Smarty extends Smarty_Internal_TemplateBase
* - make it absolute if required
*
* @param string $path file path
* @param bool $realpath if true - convert to absolute
* false - convert to relative
* null - keep as it is but remove /./ /../
* @param bool $realpath leave $path relative
*
* @return string
*/
@@ -1181,13 +1178,9 @@ class Smarty extends Smarty_Internal_TemplateBase
$path = str_replace($nds, DS, $path);
}
if (DS != '/' && $path[ 0 ] == DS) {
$path = substr(getcwd(), 0, 2) . $path;
} else {
if ($realpath === true && $path[ 0 ] !== '/' && $path[ 1 ] !== ':') {
if ($realpath === true && (($path[0] !== '/' && DS == '/') || ($path[1] !== ':' && DS != '/'))) {
$path = getcwd() . DS . $path;
}
}
while ((strpos($path, '.' . DS) !== false) || (strpos($path, DS . DS) !== false)) {
$path = preg_replace($pattern, DS, $path);
}