diff --git a/application/dashboard.class.inc.php b/application/dashboard.class.inc.php index 1a8332773..9955162a9 100644 --- a/application/dashboard.class.inc.php +++ b/application/dashboard.class.inc.php @@ -674,28 +674,29 @@ class RuntimeDashboard extends Dashboard { $bCustomized = false; - if (!appUserPreferences::GetPref('display_original_dashboard_'.$sDashBoardId, false)) - { + $sDashboardFileSanitized = utils::RealPath($sDashboardFile, APPROOT); + if (false === $sDashboardFileSanitized) { + throw new SecurityException('Invalid dashboard file !'); + } + + if (!appUserPreferences::GetPref('display_original_dashboard_'.$sDashBoardId, false)) { // Search for an eventual user defined dashboard $oUDSearch = new DBObjectSearch('UserDashboard'); $oUDSearch->AddCondition('user_id', UserRights::GetUserId(), '='); $oUDSearch->AddCondition('menu_code', $sDashBoardId, '='); $oUDSet = new DBObjectSet($oUDSearch); - if ($oUDSet->Count() > 0) - { + if ($oUDSet->Count() > 0) { // Assuming there is at most one couple {user, menu}! $oUserDashboard = $oUDSet->Fetch(); $sDashboardDefinition = $oUserDashboard->Get('contents'); $bCustomized = true; - } - else - { - $sDashboardDefinition = @file_get_contents($sDashboardFile); + } else { + $sDashboardDefinition = @file_get_contents($sDashboardFileSanitized); } } else { - $sDashboardDefinition = @file_get_contents($sDashboardFile); + $sDashboardDefinition = @file_get_contents($sDashboardFileSanitized); } if ($sDashboardDefinition !== false) @@ -703,7 +704,7 @@ class RuntimeDashboard extends Dashboard $oDashboard = new RuntimeDashboard($sDashBoardId); $oDashboard->FromXml($sDashboardDefinition); $oDashboard->SetCustomFlag($bCustomized); - $oDashboard->SetDefinitionFile($sDashboardFile); + $oDashboard->SetDefinitionFile($sDashboardFileSanitized); } else {