summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUwe.Tews@googlemail.com <Uwe.Tews@googlemail.com>2014-02-16 18:34:08 +0000
committerUwe.Tews@googlemail.com <Uwe.Tews@googlemail.com>2014-02-16 18:34:08 +0000
commitbfa0ce8ba4565e7bbc9a909f27f9640415c68139 (patch)
tree01bc5d5c1827e1fb5557f628e52b5d8e0f787c43
parentf242ce30fb3ad728620aca22379c0aa1da7fdf3a (diff)
downloadsmarty-bfa0ce8ba4565e7bbc9a909f27f9640415c68139.tar.gz
smarty-bfa0ce8ba4565e7bbc9a909f27f9640415c68139.tar.bz2
smarty-bfa0ce8ba4565e7bbc9a909f27f9640415c68139.zip
- bugfix a '//' or '\\' in template_dir path could produce wrong path on relative filepath in {include} (Issue 175)
-rw-r--r--change_log.txt3
-rw-r--r--libs/Smarty.class.php42
2 files changed, 28 insertions, 17 deletions
diff --git a/change_log.txt b/change_log.txt
index 684920c1..82d0d1e1 100644
--- a/change_log.txt
+++ b/change_log.txt
@@ -1,4 +1,7 @@
===== trunk =====
+ 16.02.2014
+ - bugfix a '//' or '\\' in template_dir path could produce wrong path on relative filepath in {include} (Issue 175)
+
05.02.2014
- bugfix shared.literal_compiler_param.php did throw an exception when literal did contain a '-' (smarty-developers group)
diff --git a/libs/Smarty.class.php b/libs/Smarty.class.php
index 893ffb2e..a3edac7d 100644
--- a/libs/Smarty.class.php
+++ b/libs/Smarty.class.php
@@ -835,7 +835,7 @@ class Smarty extends Smarty_Internal_TemplateBase
{
$this->template_dir = array();
foreach ((array) $template_dir as $k => $v) {
- $this->template_dir[$k] = rtrim($v, '/\\') . DS;
+ $this->template_dir[$k] = str_replace(array('//','\\\\'), DS, rtrim($v, '/\\')) . DS;
}
$this->joined_template_dir = join(DIRECTORY_SEPARATOR, $this->template_dir);
@@ -858,20 +858,24 @@ class Smarty extends Smarty_Internal_TemplateBase
if (is_array($template_dir)) {
foreach ($template_dir as $k => $v) {
+ $v = str_replace(array('//','\\\\'), DS, rtrim($v, '/\\')) . DS;
if (is_int($k)) {
// indexes are not merged but appended
- $this->template_dir[] = rtrim($v, '/\\') . DS;
+ $this->template_dir[] = $v;
} else {
// string indexes are overridden
- $this->template_dir[$k] = rtrim($v, '/\\') . DS;
+ $this->template_dir[$k] = $v;
}
}
- } elseif ($key !== null) {
- // override directory at specified index
- $this->template_dir[$key] = rtrim($template_dir, '/\\') . DS;
- } else {
- // append new directory
- $this->template_dir[] = rtrim($template_dir, '/\\') . DS;
+ } else {
+ $v = str_replace(array('//','\\\\'), DS, rtrim($template_dir, '/\\')) . DS;
+ if ($key !== null) {
+ // override directory at specified index
+ $this->template_dir[$key] = $v;
+ } else {
+ // append new directory
+ $this->template_dir[] = $v;
+ }
}
$this->joined_template_dir = join(DIRECTORY_SEPARATOR, $this->template_dir);
@@ -903,7 +907,7 @@ class Smarty extends Smarty_Internal_TemplateBase
{
$this->config_dir = array();
foreach ((array) $config_dir as $k => $v) {
- $this->config_dir[$k] = rtrim($v, '/\\') . DS;
+ $this->config_dir[$k] = str_replace(array('//','\\\\'), DS, rtrim($v, '/\\')) . DS;
}
$this->joined_config_dir = join(DIRECTORY_SEPARATOR, $this->config_dir);
@@ -925,20 +929,24 @@ class Smarty extends Smarty_Internal_TemplateBase
if (is_array($config_dir)) {
foreach ($config_dir as $k => $v) {
+ $v = str_replace(array('//','\\\\'), DS, rtrim($v, '/\\')) . DS;
if (is_int($k)) {
// indexes are not merged but appended
- $this->config_dir[] = rtrim($v, '/\\') . DS;
+ $this->config_dir[] = $v;
} else {
// string indexes are overridden
- $this->config_dir[$k] = rtrim($v, '/\\') . DS;
+ $this->config_dir[$k] = $v;
}
}
- } elseif ($key !== null) {
- // override directory at specified index
- $this->config_dir[$key] = rtrim($config_dir, '/\\') . DS;
} else {
- // append new directory
- $this->config_dir[] = rtrim($config_dir, '/\\') . DS;
+ $v = str_replace(array('//','\\\\'), DS, rtrim($config_dir, '/\\')) . DS;
+ if ($key !== null) {
+ // override directory at specified index
+ $this->config_dir[$key] = rtrim($v, '/\\') . DS;
+ } else {
+ // append new directory
+ $this->config_dir[] = rtrim($v, '/\\') . DS;
+ }
}
$this->joined_config_dir = join(DIRECTORY_SEPARATOR, $this->config_dir);