Commit 330f4609 by Scott Tester

Implemented qiangxue's solution as it is much simpler.

parent 39265da4
...@@ -49,19 +49,15 @@ class BaseFileHelper ...@@ -49,19 +49,15 @@ class BaseFileHelper
$parts = []; $parts = [];
foreach (explode($ds, $path) as $part) { foreach (explode($ds, $path) as $part) {
if ($part === '..' && !empty($parts) && end($parts) !== '..') { if ($part === '..' && !empty($parts) && end($parts) !== '..') {
if (array_pop($parts) === ".") { array_pop($parts);
$parts[] = '..'; } elseif ($part === '.' || $part === '' && !empty($parts)) {
}
} elseif (( $part === '.' || $part === '' ) && !empty($parts)) {
continue; continue;
} else { } else {
$parts[] = $part; $parts[] = $part;
} }
} }
if (count($parts) > 1 && $parts[0] === '.') { $path = implode($ds, $parts);
array_shift($parts); return $path === '' ? '.' : $path;
}
return implode($ds, $parts);
} }
/** /**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment