Skip to content
This repository has been archived by the owner on Dec 13, 2022. It is now read-only.

Fix(security): vulnerabilities in common-Func.php #12043

Draft
wants to merge 1 commit into
base: develop
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions www/include/common/common-Func.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
*
*/

use enshrined\svgSanitize\Sanitizer;

/**
* Displays the SVG file in HTML.
*
Expand All @@ -49,9 +51,15 @@ function displaySvg(string $svgPath, string $color, float $height, float $width)
$svgPath = str_replace('.', '', $path['dirname']) . DIRECTORY_SEPARATOR . $path['basename'];
$path = _CENTREON_PATH_ . DIRECTORY_SEPARATOR . $svgPath;
if (file_exists($path)) {
$data = file_get_contents($path);
$data = str_replace('<svg ', "<svg height='$height' width='$width' ", $data);
echo "<span style='fill:$color; vertical-align: middle'>" . $data . '</span>';
$sanitizer = new Sanitizer();
$svg = file_get_contents($path);
if ($svg === false) {
echo 'Unable to get content of file: ' . $path;
} else {
$cleanSvg = $sanitizer->sanitize($svg);
$cleanSvg = str_replace('<svg ', "<svg height='$height' width='$width' ", $cleanSvg);
echo "<span style='fill:$color; vertical-align: middle'>" . $cleanSvg . '</span>';
}
} else {
echo 'SVG file not found: ' . $svgPath;
}
Expand Down