ILIAS  trunk Revision v11.0_alpha-1744-gb0451eebef4
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
FilenameSanitizerPreProcessor.php
Go to the documentation of this file.
1 <?php
2 
20 
25 
36 {
40  public function process(FileStream $stream, Metadata $metadata): ProcessingStatus
41  {
42  $filename = $metadata->getFilename();
43  // remove some special characters
45 
46  $metadata->setFilename($filename);
47 
48  return new ProcessingStatus(ProcessingStatus::OK, 'Filename changed');
49  }
50 
51  private function normalizeRelativePath(string $path): string
52  {
53  $path = str_replace('\\', '/', $path);
54  $path = preg_replace('#\p{C}+#u', '', $path);
55  $parts = [];
56 
57  foreach (explode('/', (string) $path) as $part) {
58  switch ($part) {
59  case '':
60  case '.':
61  break;
62 
63  case '..':
64  if (empty($parts)) {
65  throw new \LogicException(
66  'Path is outside of the defined root, path: [' . $path . ']'
67  );
68  }
69  array_pop($parts);
70  break;
71 
72  default:
73  $parts[] = $part;
74  break;
75  }
76  }
77 
78  return implode('/', $parts);
79  }
80 }
if($clientAssertionType !='urn:ietf:params:oauth:client-assertion-type:jwt-bearer'|| $grantType !='client_credentials') $parts
Definition: ltitoken.php:61
$path
Definition: ltiservices.php:29
static sanitizeFileName(string $filename)
Definition: Util.php:48
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$filename
Definition: buildRTE.php:78