ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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}
$filename
Definition: buildRTE.php:78
getFilename()
The filename supplied by the browser.
Definition: Metadata.php:76
setFilename(string $filename)
Overwrite the current filename.
Definition: Metadata.php:89
process(FileStream $stream, Metadata $metadata)
@inheritDoc
static sanitizeFileName(string $filename)
Definition: Util.php:48
The base interface for all filesystem streams.
Definition: FileStream.php:32
$path
Definition: ltiservices.php:30
if($clientAssertionType !='urn:ietf:params:oauth:client-assertion-type:jwt-bearer'|| $grantType !='client_credentials') $parts
Definition: ltitoken.php:61
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...