ILIAS  release_7 Revision v7.30-3-g800a261c036
ILIAS\Filesystem\Util Class Reference

This Util class is a collection of static helper methods to provide file system related functionality. More...

+ Collaboration diagram for ILIAS\Filesystem\Util:

Static Public Member Functions

static sanitizeFileName (string $filename)
 

Private Attributes

const FUNKY_WHITESPACES = '#\p{C}+#u'
 
const ZERO_JOINER = '/\\x{00ad}|\\x{0083}|\\x{200c}|\\x{200d}|\\x{2062}|\\x{2063}/iu'
 
const SOFT_HYPHEN = "/\\x{00a0}/iu"
 
const CONTROL_CHARACTER = "/\\x{00a0}/iu"
 

Detailed Description

This Util class is a collection of static helper methods to provide file system related functionality.

Currently you can use it to sanitize file names which are compatible with the ILIAS file system.

Author
Fabian Schmid fabia.nosp@m.n@sr.nosp@m..solu.nosp@m.tion.nosp@m.s

Definition at line 27 of file Util.php.

Member Function Documentation

◆ sanitizeFileName()

static ILIAS\Filesystem\Util::sanitizeFileName ( string  $filename)
static

Definition at line 34 of file Util.php.

34 : string
35 {
36 // remove control characters
37 $filename = preg_replace('/[\x00-\x1F\x7F]/u', '', $filename);
38 $filename = preg_replace(self::CONTROL_CHARACTER, '', $filename);
39
40 // remove other characters
41 $filename = preg_replace(self::FUNKY_WHITESPACES, '', $filename);
42 $filename = preg_replace(self::SOFT_HYPHEN, ' ', $filename);
43 $filename = preg_replace(self::ZERO_JOINER, '', $filename);
44
45 // UTF normalization form C
46 return \UtfNormal::NFC($filename);
47 }
$filename
Definition: buildRTE.php:89

References $filename.

Referenced by ILIAS\FileUpload\Processor\FilenameSanitizerPreProcessor\process(), and ILIAS\Filesystem\Security\Sanitizing\FilenameSanitizerImpl\sanitize().

+ Here is the caller graph for this function:

Field Documentation

◆ CONTROL_CHARACTER

const ILIAS\Filesystem\Util::CONTROL_CHARACTER = "/\\x{00a0}/iu"
private

Definition at line 32 of file Util.php.

◆ FUNKY_WHITESPACES

const ILIAS\Filesystem\Util::FUNKY_WHITESPACES = '#\p{C}+#u'
private

Definition at line 29 of file Util.php.

◆ SOFT_HYPHEN

const ILIAS\Filesystem\Util::SOFT_HYPHEN = "/\\x{00a0}/iu"
private

Definition at line 31 of file Util.php.

◆ ZERO_JOINER

const ILIAS\Filesystem\Util::ZERO_JOINER = '/\\x{00ad}|\\x{0083}|\\x{200c}|\\x{200d}|\\x{2062}|\\x{2063}/iu'
private

Definition at line 30 of file Util.php.


The documentation for this class was generated from the following file: