From b64cdd68a3e9edff894542f65302190d39921902 Mon Sep 17 00:00:00 2001 From: Squidly271 Date: Sun, 7 Mar 2021 15:48:01 -0500 Subject: [PATCH] Protect GUI from invalid .page files If the format of the .page is completely wrong, then every page gets corrupted, and the system becomes unusable. Personally, I hate it that every .page file can potentially take down the entire GUI in case of an error. Blocking the output of the parse_ini_file protects the GUI, and the file gets logged to inform the user / forum. --- plugins/dynamix/include/PageBuilder.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/dynamix/include/PageBuilder.php b/plugins/dynamix/include/PageBuilder.php index 8d4266f1f..f7f83ea12 100644 --- a/plugins/dynamix/include/PageBuilder.php +++ b/plugins/dynamix/include/PageBuilder.php @@ -31,7 +31,8 @@ function build_pages($pattern) { global $site; foreach (glob($pattern,GLOB_NOSORT) as $entry) { [$header, $content] = explode("---\n", file_get_contents($entry),2); - $page = parse_ini_string($header); + $page = @parse_ini_string($header); + if ( ! $page ) exec("logger -t 'webGUI' Invalid .page format: $entry"); $page['file'] = $entry; $page['root'] = dirname($entry); $page['name'] = basename($entry, '.page');