diff --git a/libraries/src/HTML/Helpers/Icons.php b/libraries/src/HTML/Helpers/Icons.php index 54dcc541c16d5..f16d545b2e6a9 100644 --- a/libraries/src/HTML/Helpers/Icons.php +++ b/libraries/src/HTML/Helpers/Icons.php @@ -12,6 +12,7 @@ use Joomla\CMS\Factory; use Joomla\CMS\HTML\HTMLHelper; +use Joomla\CMS\Filesystem\File; use Joomla\CMS\Layout\FileLayout; use Joomla\CMS\Uri\Uri; use Joomla\Filesystem\Path; @@ -114,11 +115,17 @@ public static function svg(string $file, bool $relative = true): ?string // Get path to icon $file = HTMLHelper::_('image', $file, '', '', $relative, true); + // If you can't find the icon then skip it. + if (!$file) + { + return null; + } + // Make sure path is local to Joomla $file = Path::check(JPATH_ROOT . '/' . substr($file, \strlen(Uri::root(true)))); - // If you can't find the icon or if it's unsafe then skip it - if (!$file) + // If it doesn't exist then skip it. + if (!File::exists($file)) { return null; }