ILIAS  release_7 Revision v7.30-3-g800a261c036
Util.php
Go to the documentation of this file.
1 <?php
2 declare(strict_types=1);
3 
5 
11 class Util extends \League\Flysystem\Util
12 {
13 
18  public static function normalizeRelativePath($path)
19  {
20  $path = preg_replace("#\\\\(?!['\\\])#m", '/', $path); // this only replaces backslashes
21  $path = static::removeFunkyWhiteSpace($path);
22  $parts = [];
23 
24  foreach (explode('/', $path) as $part) {
25  switch ($part) {
26  case '':
27  case '.':
28  break;
29 
30  case '..':
31  if (empty($parts)) {
32  throw new \LogicException(
33  'Path is outside of the defined root, path: [' . $path . ']'
34  );
35  }
36  array_pop($parts);
37  break;
38 
39  default:
40  $parts[] = $part;
41  break;
42  }
43  }
44 
45  $path = implode('/', $parts);
46 
47  return $path;
48  }
49 
50 }