ILIAS  trunk Revision v11.0_alpha-1846-g895b5f47236
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
WhiteAndBlacklistedFileNamePolicy.php
Go to the documentation of this file.
1 <?php
2 
20 
27 {
33  public function __construct(protected array $blacklisted = [], protected array $whitelisted = [])
34  {
35  }
36 
37  public function isValidExtension(string $extension): bool
38  {
39  $extension = strtolower($extension);
40 
41  return in_array($extension, $this->whitelisted) && !in_array($extension, $this->blacklisted);
42  }
43 
44  public function isBlockedExtension(string $extension): bool
45  {
46  $extension = strtolower($extension);
47 
48  return in_array($extension, $this->blacklisted);
49  }
50 
51  public function check(string $extension): bool
52  {
53  if ($this->isBlockedExtension($extension)) {
54  throw new FileNamePolicyException("Extension '$extension' is blacklisted.");
55  }
56  return true;
57  }
58 }
__construct(protected array $blacklisted=[], protected array $whitelisted=[])
WhiteAndBlacklistedFileNamePolicy constructor.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...