From 2f64ab3e082ee1be4018e56d99e36d6b40845c5f Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 25 Jun 2021 16:58:29 +0200 Subject: [PATCH] Validate the theming color also on CLI Signed-off-by: Joas Schilling --- apps/theming/lib/Command/UpdateConfig.php | 5 +++++ apps/theming/lib/ThemingDefaults.php | 6 +++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/apps/theming/lib/Command/UpdateConfig.php b/apps/theming/lib/Command/UpdateConfig.php index 849744077ef42..e2592c4dda414 100644 --- a/apps/theming/lib/Command/UpdateConfig.php +++ b/apps/theming/lib/Command/UpdateConfig.php @@ -128,6 +128,11 @@ protected function execute(InputInterface $input, OutputInterface $output): int $key = $key . 'Mime'; } + if ($key === 'color' && !preg_match('/^\#([0-9a-f]{3}|[0-9a-f]{6})$/i', $value)) { + $output->writeln('The given color is invalid: ' . $value . ''); + return 1; + } + $this->themingDefaults->set($key, $value); $output->writeln('Updated ' . $key . ' to ' . $value . ''); diff --git a/apps/theming/lib/ThemingDefaults.php b/apps/theming/lib/ThemingDefaults.php index 19c20be28e1fb..59f32d0a8168f 100644 --- a/apps/theming/lib/ThemingDefaults.php +++ b/apps/theming/lib/ThemingDefaults.php @@ -213,7 +213,11 @@ public function getShortFooter() { * @return string */ public function getColorPrimary() { - return $this->config->getAppValue('theming', 'color', $this->color); + $color = $this->config->getAppValue('theming', 'color', $this->color); + if (!preg_match('/^\#([0-9a-f]{3}|[0-9a-f]{6})$/i', $color)) { + $color = '#0082c9'; + } + return $color; } /**