Skip to content

Commit

Permalink
static/img: Make sure to correctly access module images
Browse files Browse the repository at this point in the history
fixes #4226

(cherry picked from commit 3035efa)
  • Loading branch information
nilmerg committed Aug 14, 2020
1 parent 999e76e commit c6baff2
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions application/controllers/StaticController.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,16 +68,16 @@ public function gravatarAction()
*/
public function imgAction()
{
$moduleRoot = Icinga::app()
$imgRoot = Icinga::app()
->getModuleManager()
->getModule($this->getParam('module_name'))
->getBaseDir();
->getBaseDir() . '/public/img/';

$file = $this->getParam('file');
$filePath = realpath($moduleRoot . '/public/img/' . $file);
$filePath = realpath($imgRoot . $file);

if ($filePath === false) {
$this->httpNotFound('%s does not exist', $filePath);
if ($filePath === false || substr($filePath, 0, strlen($imgRoot)) !== $imgRoot) {
$this->httpNotFound('%s does not exist', $file);
}

if (preg_match('/\.([a-z]+)$/i', $file, $m)) {
Expand Down

0 comments on commit c6baff2

Please sign in to comment.