From da571d039980f8ab16eb3e3c18ddaea4ee829037 Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Thu, 7 Nov 2024 09:02:28 -0800 Subject: [PATCH] Handle empty google fonts field better Signed-off-by: Matt Friedman --- controller/acp_controller.php | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/controller/acp_controller.php b/controller/acp_controller.php index 6d006044..54e9f159 100644 --- a/controller/acp_controller.php +++ b/controller/acp_controller.php @@ -189,9 +189,19 @@ protected function get_google_fonts() protected function save_google_fonts() { $fonts = $this->request->variable('abbc3_google_fonts', ''); - $fonts = explode("\n", $fonts); - $this->validate_google_fonts($fonts); - $this->config_text->set('abbc3_google_fonts', json_encode($fonts)); + if (!empty($fonts)) + { + $fonts = explode("\n", $fonts); + $fonts = array_filter($fonts, 'strlen'); // Remove empty strings + + if (!empty($fonts)) + { + $this->validate_google_fonts($fonts); + } + } + + $fonts = (is_array($fonts) && !empty($fonts)) ? json_encode($fonts) : ''; + $this->config_text->set('abbc3_google_fonts', $fonts); } /**