ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
ilMediaSvgSanitizer Class Reference

Small wrapper for svg sanitizer. More...

+ Collaboration diagram for ilMediaSvgSanitizer:

Static Public Member Functions

static sanitizeFile ($a_file)
 Sanitize (temporary solution for sec issue 20339, ILIAS 5.0-5.2, not using composer autoloading yet) More...
 
static sanitizeDir ($a_path)
 Sanitize directory recursively. More...
 

Detailed Description

Small wrapper for svg sanitizer.

Author
Alex Killing alex..nosp@m.kill.nosp@m.ing@g.nosp@m.mx.d.nosp@m.e
Version
$Id$

Definition at line 15 of file class.ilMediaSvgSanitizer.php.

Member Function Documentation

◆ sanitizeDir()

static ilMediaSvgSanitizer::sanitizeDir (   $a_path)
static

Sanitize directory recursively.

Parameters
$a_path

Definition at line 41 of file class.ilMediaSvgSanitizer.php.

References $path.

Referenced by ilObjMediaObject\_saveTempFileAsMediaObject(), ilObjMediaObjectGUI\executeCommand(), ilMediaObjectDataSet\importRecord(), ilObjMediaObjectGUI\savePropertiesObject(), ilObjMediaObjectGUI\setObjectPerCreationForm(), ilObjMediaObject\uploadAdditionalFile(), and ilObjMediaObjectGUI\uploadFileObject().

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  }
$path
Definition: aliased.php:25
+ Here is the caller graph for this function:

◆ sanitizeFile()

static ilMediaSvgSanitizer::sanitizeFile (   $a_file)
static

Sanitize (temporary solution for sec issue 20339, ILIAS 5.0-5.2, not using composer autoloading yet)

Parameters
string$a_filefile to be sanitized

Definition at line 22 of file class.ilMediaSvgSanitizer.php.

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  }

The documentation for this class was generated from the following file: