mirror of
https://github.com/unraid/webgui.git
synced 2026-01-05 17:20:04 -06:00
fix: parse_plugin_cfg(): better handling of corrupt ini files
This commit is contained in:
@@ -52,8 +52,24 @@ function parse_plugin_cfg($plugin, $sections=false, $scanner=INI_SCANNER_NORMAL)
|
||||
global $docroot;
|
||||
$ram = "$docroot/plugins/$plugin/default.cfg";
|
||||
$rom = "/boot/config/plugins/$plugin/$plugin.cfg";
|
||||
$cfg = file_exists($ram) ? my_parse_ini_file($ram, $sections, $scanner) : [];
|
||||
return file_exists($rom) ? array_replace_recursive($cfg, my_parse_ini_file($rom, $sections, $scanner)) : $cfg;
|
||||
|
||||
$cfg_ram = [];
|
||||
if (file_exists($ram)) {
|
||||
$cfg_ram = my_parse_ini_file($ram, $sections, $scanner);
|
||||
if ($cfg_ram === false) {
|
||||
my_logger("Failed to parse config file: $ram", 'webgui');
|
||||
$cfg_ram = [];
|
||||
}
|
||||
}
|
||||
$cfg_rom = [];
|
||||
if (file_exists($rom)) {
|
||||
$cfg_rom = my_parse_ini_file($rom, $sections, $scanner);
|
||||
if ($cfg_rom === false) {
|
||||
my_logger("Failed to parse config file: $rom", 'webgui');
|
||||
$cfg_rom = [];
|
||||
}
|
||||
}
|
||||
return !empty($cfg_rom) ? array_replace_recursive($cfg_ram, $cfg_rom) : $cfg_ram;
|
||||
}
|
||||
|
||||
function parse_cron_cfg($plugin, $job, $text = "") {
|
||||
|
||||
Reference in New Issue
Block a user