ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
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
5use enshrined\svgSanitize\Sanitizer;
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") {
49 }
50 }
51 }
52}
An exception for terminatinating execution or to throw for unit testing.
Small wrapper for svg sanitizer.
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.
if($format !==null) $name
Definition: metadata.php:230