ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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  public 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  public 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  if (strtolower(pathinfo($name, PATHINFO_EXTENSION)) == "svg") {
48  self::sanitizeFile($name);
49  }
50  }
51  }
52 }
static sanitizeFile($a_file)
Sanitize (temporary solution for sec issue 20339, ILIAS 5.0-5.2, not using composer autoloading yet) ...
static sanitizeDir($a_path)
Sanitize directory recursively.
Small wrapper for svg sanitizer.
if($format !==null) $name
Definition: metadata.php:146
if(empty( $files_to_scan)) $sanitizer
Definition: svg-scanner.php:90