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