Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2021-06-25 17:58:29 +0300
committerJoas Schilling <coding@schilljs.com>2021-06-25 17:58:29 +0300
commit080e26fb809e5e7d144a0fd9518f8a0c5f6d85e4 (patch)
treec4469521d273dd65a65c698c8515655784dcea1b /apps/theming
parent00edbc2adf4d9362041f5611c62967f5a70e5b7e (diff)
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.php5
-rw-r--r--apps/theming/lib/ThemingDefaults.php6
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;
}
/**