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;
}
/**