Skip to content

Commit

Permalink
Merge pull request #3734 from nextcloud/enh/noid/add-json-decode-and-…
Browse files Browse the repository at this point in the history
…encode
  • Loading branch information
szaimen authored Nov 15, 2023
2 parents e60331e + 40d7c05 commit ea5965c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions php/src/Data/ConfigurationManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public function GetConfig() : array
if(file_exists(DataConst::GetConfigFile()))
{
$configContent = file_get_contents(DataConst::GetConfigFile());
return json_decode($configContent, true);
return json_decode($configContent, true, 512, JSON_THROW_ON_ERROR);
}

return [];
Expand Down Expand Up @@ -514,7 +514,7 @@ public function WriteConfig(array $config) : void {
throw new InvalidSettingConfigurationException(DataConst::GetDataDirectory() . " does not exist! Something was set up falsely!");
}
$df = disk_free_space(DataConst::GetDataDirectory());
$content = json_encode($config, JSON_UNESCAPED_SLASHES|JSON_PRETTY_PRINT);
$content = json_encode($config, JSON_UNESCAPED_SLASHES|JSON_PRETTY_PRINT|JSON_THROW_ON_ERROR);
$size = strlen($content) + 10240;
if ($df !== false && (int)$df < $size) {
throw new InvalidSettingConfigurationException(DataConst::GetDataDirectory() . " does not have enough space for writing the config file! Not writing it back!");
Expand Down

0 comments on commit ea5965c

Please sign in to comment.