Merge pull request #4227 from Icinga/fix/incorrect-module-image-delivery

static/img: Make sure to correctly access module images
This commit is contained in:
Johannes Meyer 2020-08-19 11:02:23 +02:00 committed by GitHub
commit 86ca586dd6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -68,16 +68,16 @@ class StaticController extends Controller
*/ */
public function imgAction() public function imgAction()
{ {
$moduleRoot = Icinga::app() $imgRoot = Icinga::app()
->getModuleManager() ->getModuleManager()
->getModule($this->getParam('module_name')) ->getModule($this->getParam('module_name'))
->getBaseDir(); ->getBaseDir() . '/public/img/';
$file = $this->getParam('file'); $file = $this->getParam('file');
$filePath = realpath($moduleRoot . '/public/img/' . $file); $filePath = realpath($imgRoot . $file);
if ($filePath === false) { if ($filePath === false || substr($filePath, 0, strlen($imgRoot)) !== $imgRoot) {
$this->httpNotFound('%s does not exist', $filePath); $this->httpNotFound('%s does not exist', $file);
} }
if (preg_match('/\.([a-z]+)$/i', $file, $m)) { if (preg_match('/\.([a-z]+)$/i', $file, $m)) {