ILIAS  trunk Revision v11.0_alpha-1713-gd8962da2f67
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
class.ilMediaSvgSanitizer.php
Go to the documentation of this file.
1 <?php
2 
20 
27 {
32  public static function sanitizeFile(
33  string $a_file
34  ): void {
35  $sanitizer = new Sanitizer();
36  $dirtySVG = file_get_contents($a_file);
37  $cleanSVG = $sanitizer->sanitize($dirtySVG);
38  file_put_contents($a_file, $cleanSVG);
39  }
40 
44  public static function sanitizeDir(
45  string $a_path
46  ): void {
47  $path = realpath($a_path);
48 
49  $objects = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path), RecursiveIteratorIterator::SELF_FIRST);
50  foreach ($objects as $name => $object) {
51  if (strtolower(pathinfo($name, PATHINFO_EXTENSION)) == "svg") {
52  self::sanitizeFile($name);
53  }
54  }
55  }
56 }
static sanitizeDir(string $a_path)
Sanitize directory recursively.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$path
Definition: ltiservices.php:29
Small wrapper for svg sanitizer.
static sanitizeFile(string $a_file)
Sanitize (temporary solution for sec issue 20339, ILIAS 5.0-5.2, not using composer autoloading yet) ...