- optimize filepath normalization

This commit is contained in:
uwetews
2015-10-18 04:40:45 +02:00
parent 757d66a731
commit ca9ccfc919
3 changed files with 19 additions and 7 deletions
@@ -49,6 +49,10 @@ class Smarty_Internal_Resource_File extends Smarty_Resource
// files relative to a template only get one shot
return is_file($path) ? $path : false;
}
// normalize DS
if (strpos($file, DS == '/' ? '\\' : '/') !== false) {
$file = str_replace(DS == '/' ? '\\' : '/', DS, $file);
}
$_directories = $source->smarty->getTemplateDir(null, $source->isConfig);
// template_dir index?
@@ -87,7 +91,7 @@ class Smarty_Internal_Resource_File extends Smarty_Resource
foreach ($_directories as $_directory) {
$path = $_directory . $file;
if (is_file($path)) {
return $source->smarty->_realpath($path);
return (strpos($path, '.' . DS) !== false) ? $source->smarty->_realpath($path) : $path;
}
}
if (!isset($_index_dirs)) {