replace constant DS with DIRECTORY_SEPARATOR

This commit is contained in:
uwetews
2016-08-23 07:56:09 +02:00
parent 490fb5eaa5
commit be86d1eb6d
7 changed files with 15 additions and 15 deletions

View File

@@ -431,12 +431,12 @@ KEY `expire` (`expire`)
public function normalizePath($path) public function normalizePath($path)
{ {
if ($path[ 0 ] == '.') { if ($path[ 0 ] == '.') {
$path = getcwd() . DS . $path; $path = getcwd() . DIRECTORY_SEPARATOR . $path;
} }
$path = preg_replace('#[\\\/]+([.][\\\/]+)*#', DS, $path); $path = preg_replace('#[\\\/]+([.][\\\/]+)*#', DIRECTORY_SEPARATOR, $path);
while (strrpos($path, '.' . DS) !== false) { while (strrpos($path, '.' . DIRECTORY_SEPARATOR) !== false) {
$path = $path =
preg_replace('#([\\\/]([^\\\/]+[\\\/]){2}([.][.][\\\/]){2})|([\\\/][^\\\/]+[\\\/][.][.][\\\/])#', DS, preg_replace('#([\\\/]([^\\\/]+[\\\/]){2}([.][.][\\\/]){2})|([\\\/][^\\\/]+[\\\/][.][.][\\\/])#', DIRECTORY_SEPARATOR,
$path); $path);
} }
return $path; return $path;
@@ -489,7 +489,7 @@ KEY `expire` (`expire`)
public function buildCompiledPath(Smarty_Internal_Template $tpl, $sub = true, $caching = false, $compile_id = null, public function buildCompiledPath(Smarty_Internal_Template $tpl, $sub = true, $caching = false, $compile_id = null,
$name = null, $type = null, $dir = null) $name = null, $type = null, $dir = null)
{ {
$sep = DS; $sep = DIRECTORY_SEPARATOR;
$_compile_id = isset($compile_id) ? preg_replace('![^\w\|]+!', '_', $compile_id) : null; $_compile_id = isset($compile_id) ? preg_replace('![^\w\|]+!', '_', $compile_id) : null;
$sp = $this->buildSourcePath($tpl, $name, $type, $dir); $sp = $this->buildSourcePath($tpl, $name, $type, $dir);
$uid = $this->buildUid($tpl, $sp, $name, $type); $uid = $this->buildUid($tpl, $sp, $name, $type);
@@ -553,7 +553,7 @@ KEY `expire` (`expire`)
switch ($cacheType) { switch ($cacheType) {
case 'file': case 'file':
case 'filetest': case 'filetest':
$sep = DS; $sep = DIRECTORY_SEPARATOR;
$_compile_id = isset($compile_id) ? preg_replace('![^\w\|]+!', '_', $compile_id) : null; $_compile_id = isset($compile_id) ? preg_replace('![^\w\|]+!', '_', $compile_id) : null;
$_cache_id = isset($cache_id) ? preg_replace('![^\w\|]+!', '_', $cache_id) : null; $_cache_id = isset($cache_id) ? preg_replace('![^\w\|]+!', '_', $cache_id) : null;
$sp = $this->buildSourcePath($tpl, $name, $type, $dir); $sp = $this->buildSourcePath($tpl, $name, $type, $dir);

View File

@@ -17,7 +17,7 @@ class IncludePathTest extends PHPUnit_Smarty
$this->smarty->use_include_path = true; $this->smarty->use_include_path = true;
$this->smarty->setPluginsDir(array('./include','./include1')); $this->smarty->setPluginsDir(array('./include','./include1'));
$this->smarty->enableSecurity(); $this->smarty->enableSecurity();
$ds = DS; $ds = DIRECTORY_SEPARATOR;
set_include_path($this->smarty->_realpath(dirname(__FILE__) . "{$ds}..{$ds}..{$ds}..{$ds}Include_Path{$ds}Plugins{$ds}", true) . PATH_SEPARATOR . get_include_path()); set_include_path($this->smarty->_realpath(dirname(__FILE__) . "{$ds}..{$ds}..{$ds}..{$ds}Include_Path{$ds}Plugins{$ds}", true) . PATH_SEPARATOR . get_include_path());
} }

View File

@@ -37,7 +37,7 @@ class CustomResourceAmbiguousTest extends PHPUnit_Smarty
protected function relative($path) protected function relative($path)
{ {
$path = str_replace(dirname(__FILE__), '.', $path); $path = str_replace(dirname(__FILE__), '.', $path);
if (DS == "\\") { if (DIRECTORY_SEPARATOR == "\\") {
$path = str_replace("\\", "/", $path); $path = str_replace("\\", "/", $path);
} }

View File

@@ -13,7 +13,7 @@ class Smarty_Resource_Ambiguous extends Smarty_Internal_Resource_File
public function __construct($directory) public function __construct($directory)
{ {
$this->directory = rtrim($directory, "/\\") . DS; $this->directory = rtrim($directory, "/\\") . DIRECTORY_SEPARATOR;
// parent::__construct(); // parent::__construct();
} }
@@ -45,7 +45,7 @@ class Smarty_Resource_Ambiguous extends Smarty_Internal_Resource_File
{ {
$segment = ''; $segment = '';
if ($this->segment) { if ($this->segment) {
$segment = rtrim($this->segment, "/\\") . DS; $segment = rtrim($this->segment, "/\\") . DIRECTORY_SEPARATOR;
} }
$source->filepath = $this->directory . $segment . $source->name; $source->filepath = $this->directory . $segment . $source->name;

View File

@@ -17,7 +17,7 @@ class FileIncludePathTest extends PHPUnit_Smarty
$this->smarty->use_include_path = true; $this->smarty->use_include_path = true;
$this->smarty->setTemplateDir(array('./templates', './templates_2', './include')); $this->smarty->setTemplateDir(array('./templates', './templates_2', './include'));
$this->smarty->enableSecurity(); $this->smarty->enableSecurity();
$ds = DS; $ds = DIRECTORY_SEPARATOR;
set_include_path($this->smarty->_realpath(dirname(__FILE__) . "{$ds}..{$ds}..{$ds}..{$ds}Include_Path{$ds}Tpl{$ds}", true) . PATH_SEPARATOR . get_include_path()); set_include_path($this->smarty->_realpath(dirname(__FILE__) . "{$ds}..{$ds}..{$ds}..{$ds}Include_Path{$ds}Tpl{$ds}", true) . PATH_SEPARATOR . get_include_path());
} }

View File

@@ -29,7 +29,7 @@ class StringResourceTest extends PHPUnit_Smarty
protected function relative($path) protected function relative($path)
{ {
$path = str_replace(dirname(__FILE__), '.', $path); $path = str_replace(dirname(__FILE__), '.', $path);
if (DS == "\\") { if (DIRECTORY_SEPARATOR == "\\") {
$path = str_replace("\\", "/", $path); $path = str_replace("\\", "/", $path);
} }

View File

@@ -343,13 +343,13 @@ class SecurityTest extends PHPUnit_Smarty
public function testChangedTrustedDirectory() public function testChangedTrustedDirectory()
{ {
$this->smarty->security_policy->secure_dir = array( $this->smarty->security_policy->secure_dir = array(
'.' . DS . 'templates_2' . DS, '.' . DIRECTORY_SEPARATOR . 'templates_2' . DIRECTORY_SEPARATOR,
); );
$this->assertEquals("hello world", $this->smarty->fetch('eval:{include file="templates_2/hello.tpl"}')); $this->assertEquals("hello world", $this->smarty->fetch('eval:{include file="templates_2/hello.tpl"}'));
$this->smarty->security_policy->secure_dir = array( $this->smarty->security_policy->secure_dir = array(
'.' . DS . 'templates_2' . DS, '.' . DIRECTORY_SEPARATOR . 'templates_2' . DIRECTORY_SEPARATOR,
'.' . DS . 'templates_3' . DS, '.' . DIRECTORY_SEPARATOR . 'templates_3' . DIRECTORY_SEPARATOR,
); );
$this->assertEquals("templates_3", $this->smarty->fetch('eval:{include file="templates_3/dirname.tpl"}')); $this->assertEquals("templates_3", $this->smarty->fetch('eval:{include file="templates_3/dirname.tpl"}'));
} }