ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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 29 of file Util.php.

Member Function Documentation

◆ sanitizeFileName()

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

Definition at line 48 of file Util.php.

48 : string
49 {
50 // remove control characters
51 $filename = preg_replace('/[\x00-\x1F\x7F]/u', '', $filename);
52 $filename = preg_replace(self::CONTROL_CHARACTER, '', (string) $filename);
53
54 // remove other characters
55 $filename = preg_replace(self::FUNKY_WHITESPACES, '', (string) $filename);
56 $filename = preg_replace(self::SOFT_HYPHEN, ' ', (string) $filename);
57 $filename = preg_replace(self::ZERO_JOINER, '', (string) $filename);
58
59 // UTF normalization form C
60 $form_c = (new UTFNormal())->formC();
61 $filename = $form_c->transform($filename);
62
63 return $filename;
64 }
$filename
Definition: buildRTE.php:78

References $filename.

Referenced by ILIAS\Filesystem\Util\Archive\Unzip\extract(), 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 46 of file Util.php.

◆ FUNKY_WHITESPACES

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

Definition at line 34 of file Util.php.

◆ SOFT_HYPHEN

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

Definition at line 42 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 38 of file Util.php.


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