Skip to content

Commit

Permalink
- bugfix templates filepath with multibyte characters did not work
Browse files Browse the repository at this point in the history
  • Loading branch information
uwetews committed Aug 26, 2017
1 parent f90b449 commit 94c2ab7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 2 additions & 0 deletions change_log.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
26.8.2017
- bugfix chained modifier failed when last modifier parameter is a signed value
https://github.com/smarty-php/smarty/issues/327
- bugfix templates filepath with multibyte characters did not work
https://github.com/smarty-php/smarty/issues/385

09.8.2017
- improvement repeated delimiter like {{ and }} will be treated as literal
Expand Down
10 changes: 5 additions & 5 deletions libs/Smarty.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ class Smarty extends Smarty_Internal_TemplateBase
/**
* smarty version
*/
const SMARTY_VERSION = '3.1.32-dev-20';
const SMARTY_VERSION = '3.1.32-dev-21';

/**
* define variable scopes
Expand Down Expand Up @@ -1213,7 +1213,7 @@ public function _realpath($path, $realpath = null)
$nds = $this->ds == '/' ? '\\' : '/';
// normalize $this->ds
$path = str_replace($nds, $this->ds, $path);
preg_match('%^(?<root>(?:[[:alpha:]]:[\\\\]|/|[\\\\]{2}[[:alpha:]]+|[[:print:]]{2,}:[/]{2}|[\\\\])?)(?<path>(?:[[:print:]]*))$%',
preg_match('%^(?<root>(?:[[:alpha:]]:[\\\\]|/|[\\\\]{2}[[:alpha:]]+|[[:print:]]{2,}:[/]{2}|[\\\\])?)(?<path>(.*))$%u',
$path, $parts);
$path = $parts[ 'path' ];
if ($parts[ 'root' ] == '\\') {
Expand All @@ -1224,10 +1224,10 @@ public function _realpath($path, $realpath = null)
}
}
// remove noop 'DIRECTORY_SEPARATOR DIRECTORY_SEPARATOR' and 'DIRECTORY_SEPARATOR.DIRECTORY_SEPARATOR' patterns
$path = preg_replace('#([\\\\/]([.]?[\\\\/])+)#', $this->ds, $path);
$path = preg_replace('#([\\\\/]([.]?[\\\\/])+)#u', $this->ds, $path);
// resolve '..DIRECTORY_SEPARATOR' pattern, smallest first
if (strpos($path, '..' . $this->ds) != false &&
preg_match_all('#(([.]?[\\\\/])*([.][.])[\\\\/]([.]?[\\\\/])*)+#', $path, $match)
preg_match_all('#(([.]?[\\\\/])*([.][.])[\\\\/]([.]?[\\\\/])*)+#u', $path, $match)
) {
$counts = array();
foreach ($match[ 0 ] as $m) {
Expand All @@ -1236,7 +1236,7 @@ public function _realpath($path, $realpath = null)
sort($counts);
foreach ($counts as $count) {
$path = preg_replace('#(([\\\\/]([.]?[\\\\/])*[^\\\\/.]+){' . $count .
'}[\\\\/]([.]?[\\\\/])*([.][.][\\\\/]([.]?[\\\\/])*){' . $count . '})(?=[^.])#',
'}[\\\\/]([.]?[\\\\/])*([.][.][\\\\/]([.]?[\\\\/])*){' . $count . '})(?=[^.])#u',
$this->ds, $path);
}
}
Expand Down

0 comments on commit 94c2ab7

Please sign in to comment.