ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilMediaSvgSanitizer.php
Go to the documentation of this file.
1<?php
2
19use enshrined\svgSanitize\Sanitizer;
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}
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)
static sanitizeDir(string $a_path)
Sanitize directory recursively.
$path
Definition: ltiservices.php:30