- bugfix a '//' or '\\' in template_dir path could produce wrong path on relative filepath in {include} (Issue 175)

This commit is contained in:
Uwe.Tews@googlemail.com
2014-02-16 18:34:08 +00:00
parent f242ce30fb
commit bfa0ce8ba4
2 changed files with 28 additions and 17 deletions

View File

@@ -1,4 +1,7 @@
===== trunk ===== ===== 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 05.02.2014
- bugfix shared.literal_compiler_param.php did throw an exception when literal did contain a '-' (smarty-developers group) - bugfix shared.literal_compiler_param.php did throw an exception when literal did contain a '-' (smarty-developers group)

View File

@@ -835,7 +835,7 @@ class Smarty extends Smarty_Internal_TemplateBase
{ {
$this->template_dir = array(); $this->template_dir = array();
foreach ((array) $template_dir as $k => $v) { 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); $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)) { if (is_array($template_dir)) {
foreach ($template_dir as $k => $v) { foreach ($template_dir as $k => $v) {
$v = str_replace(array('//','\\\\'), DS, rtrim($v, '/\\')) . DS;
if (is_int($k)) { if (is_int($k)) {
// indexes are not merged but appended // indexes are not merged but appended
$this->template_dir[] = rtrim($v, '/\\') . DS; $this->template_dir[] = $v;
} else { } else {
// string indexes are overridden // string indexes are overridden
$this->template_dir[$k] = rtrim($v, '/\\') . DS; $this->template_dir[$k] = $v;
} }
} }
} elseif ($key !== null) { } else {
$v = str_replace(array('//','\\\\'), DS, rtrim($template_dir, '/\\')) . DS;
if ($key !== null) {
// override directory at specified index // override directory at specified index
$this->template_dir[$key] = rtrim($template_dir, '/\\') . DS; $this->template_dir[$key] = $v;
} else { } else {
// append new directory // append new directory
$this->template_dir[] = rtrim($template_dir, '/\\') . DS; $this->template_dir[] = $v;
}
} }
$this->joined_template_dir = join(DIRECTORY_SEPARATOR, $this->template_dir); $this->joined_template_dir = join(DIRECTORY_SEPARATOR, $this->template_dir);
@@ -903,7 +907,7 @@ class Smarty extends Smarty_Internal_TemplateBase
{ {
$this->config_dir = array(); $this->config_dir = array();
foreach ((array) $config_dir as $k => $v) { 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); $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)) { if (is_array($config_dir)) {
foreach ($config_dir as $k => $v) { foreach ($config_dir as $k => $v) {
$v = str_replace(array('//','\\\\'), DS, rtrim($v, '/\\')) . DS;
if (is_int($k)) { if (is_int($k)) {
// indexes are not merged but appended // indexes are not merged but appended
$this->config_dir[] = rtrim($v, '/\\') . DS; $this->config_dir[] = $v;
} else { } else {
// string indexes are overridden // string indexes are overridden
$this->config_dir[$k] = rtrim($v, '/\\') . DS; $this->config_dir[$k] = $v;
} }
} }
} elseif ($key !== null) { } else {
$v = str_replace(array('//','\\\\'), DS, rtrim($config_dir, '/\\')) . DS;
if ($key !== null) {
// override directory at specified index // override directory at specified index
$this->config_dir[$key] = rtrim($config_dir, '/\\') . DS; $this->config_dir[$key] = rtrim($v, '/\\') . DS;
} else { } else {
// append new directory // append new directory
$this->config_dir[] = rtrim($config_dir, '/\\') . DS; $this->config_dir[] = rtrim($v, '/\\') . DS;
}
} }
$this->joined_config_dir = join(DIRECTORY_SEPARATOR, $this->config_dir); $this->joined_config_dir = join(DIRECTORY_SEPARATOR, $this->config_dir);