From 7b469c1f4acb1ef4b38ccb2b533be17ccd058bd9 Mon Sep 17 00:00:00 2001 From: Uwe Tews Date: Thu, 18 Jun 2015 01:46:35 +0200 Subject: [PATCH] - bugfix file path normalization failed on path containing something like "/.foo/" https://github.com/smarty-php/smarty/issues/56 --- change_log.txt | 3 +++ libs/Smarty.class.php | 2 +- libs/sysplugins/smarty_internal_resource_file.php | 9 +++------ 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/change_log.txt b/change_log.txt index 3bc68c43..412b9480 100644 --- a/change_log.txt +++ b/change_log.txt @@ -1,4 +1,7 @@  ===== 3.1.26-dev===== (xx.xx.2015) +18.06.2015 + - bugfix file path normalization failed on path containing something like "/.foo/" https://github.com/smarty-php/smarty/issues/56 + 17.06.2015 - bugfix calling a plugin with nocache option but no other attributes like {foo nocache} caused call to undefined function https://github.com/smarty-php/smarty/issues/55 diff --git a/libs/Smarty.class.php b/libs/Smarty.class.php index 4f5a6022..02ab10fb 100644 --- a/libs/Smarty.class.php +++ b/libs/Smarty.class.php @@ -111,7 +111,7 @@ class Smarty extends Smarty_Internal_TemplateBase /** * smarty version */ - const SMARTY_VERSION = '3.1.26-dev/1'; + const SMARTY_VERSION = '3.1.26-dev/2'; /** * define variable scopes diff --git a/libs/sysplugins/smarty_internal_resource_file.php b/libs/sysplugins/smarty_internal_resource_file.php index 1c705190..e8fe9e6c 100644 --- a/libs/sysplugins/smarty_internal_resource_file.php +++ b/libs/sysplugins/smarty_internal_resource_file.php @@ -17,9 +17,6 @@ */ class Smarty_Internal_Resource_File extends Smarty_Resource { - - private $dsMap = array('/' => array(array('\\', '/./'), '/.'), '\\' => array(array('/', '\\.\\'), '\\.')); - /** * build template filepath by traversing the template_dir array * @@ -127,9 +124,9 @@ class Smarty_Internal_Resource_File extends Smarty_Resource if ($path[0] == '.') { $path = getcwd() . DS . $path; } - $path = str_replace($this->dsMap[DS][0], DS, $path); - while (strrpos($path, $this->dsMap[DS][1]) !== false) { - $path = preg_replace('#([\\\/][.][\\\/])|([\\\/][^\\\/]+[\\\/][.][.][\\\/])#', DS, $path); + $path = preg_replace('#[\\\/]+([.][\\\/]+)*([.](?![.]))?#', DS, $path); + while (strrpos($path, DS . '.') !== false) { + $path = preg_replace('#([\\\/]([^\\\/]+[\\\/]){2}([.][.][\\\/]){2})|([\\\/][^\\\/]+[\\\/][.][.][\\\/]?)#', DS, $path); } return $path; }