ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilMediaSvgSanitizer.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2017 ILIAS open source, GPL, see docs/LICENSE */
4 
6 
16 {
22  static function sanitizeFile($a_file)
23  {
24  include_once("./Services/MediaObjects/lib/svg-sanitizer-master/src/data/AttributeInterface.php");
25  include_once("./Services/MediaObjects/lib/svg-sanitizer-master/src/data/TagInterface.php");
26  include_once("./Services/MediaObjects/lib/svg-sanitizer-master/src/data/AllowedTags.php");
27  include_once("./Services/MediaObjects/lib/svg-sanitizer-master/src/data/AllowedAttributes.php");
28  include_once("./Services/MediaObjects/lib/svg-sanitizer-master/src/Sanitizer.php");
29 
30  $sanitizer = new Sanitizer();
31  $dirtySVG = file_get_contents($a_file);
32  $cleanSVG = $sanitizer->sanitize($dirtySVG);
33  file_put_contents($a_file, $cleanSVG);
34  }
35 
41  static function sanitizeDir($a_path)
42  {
43  $path = realpath($a_path);
44 
45  $objects = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path), RecursiveIteratorIterator::SELF_FIRST);
46  foreach($objects as $name => $object)
47  {
48  if (strtolower(pathinfo($name, PATHINFO_EXTENSION)) == "svg")
49  {
50  self::sanitizeFile($name);
51  }
52  }
53  }
54 }
55 
56 ?>
static sanitizeFile($a_file)
Sanitize (temporary solution for sec issue 20339, ILIAS 5.0-5.2, not using composer autoloading yet) ...
$path
Definition: aliased.php:25
static sanitizeDir($a_path)
Sanitize directory recursively.
Small wrapper for svg sanitizer.