ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
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:

Data Structures

class  FilenameSanitizing
 
class  LegacyPathHelperTest
 Class LegacyPathHelperTest. More...
 

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 36 of file Util.php.

References $filename.

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

36  : string
37  {
38  // remove control characters
39  $filename = preg_replace('/[\x00-\x1F\x7F]/u', '', $filename);
40  $filename = preg_replace(self::CONTROL_CHARACTER, '', $filename);
41 
42  // remove other characters
43  $filename = preg_replace(self::FUNKY_WHITESPACES, '', $filename);
44  $filename = preg_replace(self::SOFT_HYPHEN, ' ', $filename);
45  $filename = preg_replace(self::ZERO_JOINER, '', $filename);
46 
47  // UTF normalization form C
48  $form_c = (new UTFNormal())->formC();
49  $filename = $form_c->transform($filename);
50 
51  return $filename;
52  }
$filename
Definition: buildRTE.php:78
+ 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 34 of file Util.php.

◆ FUNKY_WHITESPACES

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

Definition at line 31 of file Util.php.

◆ SOFT_HYPHEN

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

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


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