|
@@ -312,23 +312,30 @@ class Filesystem
|
|
|
$parts = array();
|
|
|
$path = strtr($path, '\\', '/');
|
|
|
$prefix = '';
|
|
|
+ $absolute = false;
|
|
|
|
|
|
- if (preg_match('{^((?:[0-9a-z]+://)?(?:[a-z]:)?/)}i', $path, $match)) {
|
|
|
+ if (preg_match('{^([0-9a-z]+:(?://(?:[a-z]:)?)?)}i', $path, $match)) {
|
|
|
$prefix = $match[1];
|
|
|
$path = substr($path, strlen($prefix));
|
|
|
}
|
|
|
|
|
|
- $appended = false;
|
|
|
+ if (substr($path, 0, 1) === '/') {
|
|
|
+ $absolute = true;
|
|
|
+ $path = substr($path, 1);
|
|
|
+ }
|
|
|
+
|
|
|
+ $up = false;
|
|
|
foreach (explode('/', $path) as $chunk) {
|
|
|
- if ('..' === $chunk && $appended) {
|
|
|
+ if ('..' === $chunk && ($absolute || $up)) {
|
|
|
array_pop($parts);
|
|
|
+ $up = !(empty($parts) || '..' === end($parts));
|
|
|
} elseif ('.' !== $chunk && '' !== $chunk) {
|
|
|
- $appended = true;
|
|
|
$parts[] = $chunk;
|
|
|
+ $up = '..' !== $chunk;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- return $prefix.implode('/', $parts);
|
|
|
+ return $prefix.($absolute ? '/' : '').implode('/', $parts);
|
|
|
}
|
|
|
|
|
|
protected function directorySize($directory)
|