diff options
author | Joas Schilling <coding@schilljs.com> | 2021-06-25 16:58:29 +0200 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2021-06-25 16:58:29 +0200 |
commit | 080e26fb809e5e7d144a0fd9518f8a0c5f6d85e4 (patch) | |
tree | c4469521d273dd65a65c698c8515655784dcea1b /apps/theming | |
parent | 00edbc2adf4d9362041f5611c62967f5a70e5b7e (diff) | |
download | nextcloud-server-080e26fb809e5e7d144a0fd9518f8a0c5f6d85e4.tar.gz nextcloud-server-080e26fb809e5e7d144a0fd9518f8a0c5f6d85e4.zip |
Validate the theming color also on CLI
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'apps/theming')
-rw-r--r-- | apps/theming/lib/Command/UpdateConfig.php | 5 | ||||
-rw-r--r-- | apps/theming/lib/ThemingDefaults.php | 6 |
2 files changed, 10 insertions, 1 deletions
diff --git a/apps/theming/lib/Command/UpdateConfig.php b/apps/theming/lib/Command/UpdateConfig.php index 3d5840fadd9..1ff75b5ba70 100644 --- a/apps/theming/lib/Command/UpdateConfig.php +++ b/apps/theming/lib/Command/UpdateConfig.php @@ -127,6 +127,11 @@ class UpdateConfig extends Command { $key = $key . 'Mime'; } + if ($key === 'color' && !preg_match('/^\#([0-9a-f]{3}|[0-9a-f]{6})$/i', $value)) { + $output->writeln('<error>The given color is invalid: ' . $value . '</error>'); + return 1; + } + $this->themingDefaults->set($key, $value); $output->writeln('<info>Updated ' . $key . ' to ' . $value . '</info>'); diff --git a/apps/theming/lib/ThemingDefaults.php b/apps/theming/lib/ThemingDefaults.php index 7e7d9a4fa13..c2ed6e305eb 100644 --- a/apps/theming/lib/ThemingDefaults.php +++ b/apps/theming/lib/ThemingDefaults.php @@ -220,7 +220,11 @@ class ThemingDefaults extends \OC_Defaults { * @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; } /** |