From aefec409625e056d4d3d81186ea3459a69f21d5b Mon Sep 17 00:00:00 2001 From: Uwe Tews Date: Sat, 27 Jun 2015 18:30:47 +0200 Subject: [PATCH] - fix special cases of filepath normalization --- libs/sysplugins/smarty_internal_resource_file.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libs/sysplugins/smarty_internal_resource_file.php b/libs/sysplugins/smarty_internal_resource_file.php index 802d9218..34a8730a 100644 --- a/libs/sysplugins/smarty_internal_resource_file.php +++ b/libs/sysplugins/smarty_internal_resource_file.php @@ -36,7 +36,7 @@ class Smarty_Internal_Resource_File extends Smarty_Resource protected function buildFilepath(Smarty_Template_Source $source, Smarty_Internal_Template $_template = null) { $file = $source->name; - $this->invDS = (DS == '/') ? '\\\\' : '\\/'; + $this->invDS = (DS == '/') ? '\\\\' : '/'; preg_match('#(^(?P[\\\/]|[a-zA-Z]:[\\\/])|(\[(?P[^\]]+)\])|(?P\.[\\\/]))|((?P\.[\\\/])|(?P[' . $this->invDS . ']))#', $file, $fileMatch); // save basename if (!empty($fileMatch['absolute'])) { @@ -99,7 +99,7 @@ class Smarty_Internal_Resource_File extends Smarty_Resource if (is_file($path)) { return $path; } - if ($source->smarty->use_include_path && !preg_match('/^([\/\\\\]|[a-zA-Z]:[\/\\\\])/', $_directory)) { + if ($source->smarty->use_include_path && !preg_match('/^([\\\/]|[a-zA-Z]:[\\\/])/', $_directory)) { // try PHP include_path if (function_exists('stream_resolve_include_path')) { $_filepath = stream_resolve_include_path($_filepath); @@ -131,7 +131,7 @@ class Smarty_Internal_Resource_File extends Smarty_Resource public function normalizePath($path) { $first = true; - while (strrpos($path, '.' . DS) !== false || ($first && strrpos($path, $this->invDS) !== false)) { + while (strrpos($path, '.' . DS) !== false || ($first && strrpos($path, $this->invDS[0]) !== false)) { $path = preg_replace('#([\\\/]+([.][\\\/]+)+)|([\\\/]+([^\\\/]+[\\\/]+){2}([.][.][\\\/]+){2})|([\\\/]+[^\\\/]+[\\\/]+[.][.][\\\/]+)|[' . $this->invDS . ']+#', DS, $path); $first = false; }