mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-05 19:04:27 +02:00
bugfix resolving relative paths broke in some circumstances (Issue #114)
This commit is contained in:
@@ -1,4 +1,7 @@
|
||||
===== trunk =====
|
||||
31.08.2012
|
||||
- bugfix resolving relative paths broke in some circumstances (Issue #114)
|
||||
|
||||
22.08.2012
|
||||
- bugfix test MBString availability through mb_split, as it could've been compiled without regex support (--enable-mbregex).
|
||||
Either we get MBstring's full package, or we pretend it's not there at all.
|
||||
|
@@ -159,16 +159,18 @@ abstract class Smarty_Resource {
|
||||
$_path = str_replace('\\', '/', $_path);
|
||||
}
|
||||
|
||||
$offset = 0;
|
||||
|
||||
// resolve simples
|
||||
$_path = preg_replace('#(/\./(\./)*)|/{2,}#', '/', $_path);
|
||||
// resolve parents
|
||||
while (true) {
|
||||
$_parent = strpos($_path, '/../');
|
||||
if ($_parent === false) {
|
||||
break;
|
||||
} else if ($_parent === 0) {
|
||||
$_path = substr($_path, 3);
|
||||
$_parent = strpos($_path, '/../', $offset);
|
||||
if (!$_parent) {
|
||||
break;
|
||||
} else if ($_path[$_parent - 1] === '.') {
|
||||
$offset = $_parent + 3;
|
||||
continue;
|
||||
}
|
||||
|
||||
$_pos = strrpos($_path, '/', $_parent - strlen($_path) - 1);
|
||||
@@ -226,7 +228,6 @@ abstract class Smarty_Resource {
|
||||
if (!preg_match('/^([\/\\\\]|[a-zA-Z]:[\/\\\\])/', $file)) {
|
||||
// don't we all just love windows?
|
||||
$_path = str_replace('\\', '/', $file);
|
||||
$_was_relative_prefix = $file[0] == '.' ? substr($file, 0, strpos($_path, '/')) : null;
|
||||
$_path = DS . trim($file, '/');
|
||||
$_was_relative = true;
|
||||
} else {
|
||||
@@ -240,12 +241,8 @@ abstract class Smarty_Resource {
|
||||
}
|
||||
// revert to relative
|
||||
if (isset($_was_relative)) {
|
||||
if (isset($_was_relative_prefix)){
|
||||
$_path = $_was_relative_prefix . $_path;
|
||||
} else {
|
||||
$_path = substr($_path, 1);
|
||||
}
|
||||
}
|
||||
|
||||
// this is only required for directories
|
||||
$file = rtrim($_path, '/\\');
|
||||
|
Reference in New Issue
Block a user