]> source.dussan.org Git - nextcloud-server.git/commitdiff
Validate the theming color also on CLI 27680/head
authorJoas Schilling <coding@schilljs.com>
Fri, 25 Jun 2021 14:58:29 +0000 (16:58 +0200)
committerbackportbot[bot] <backportbot[bot]@users.noreply.github.com>
Fri, 25 Jun 2021 16:22:27 +0000 (16:22 +0000)
Signed-off-by: Joas Schilling <coding@schilljs.com>
apps/theming/lib/Command/UpdateConfig.php
apps/theming/lib/ThemingDefaults.php

index 849744077ef42bcc71f6876028536ca675cd0080..e2592c4dda4142bcc6296c5977c1b8d5d1c87ea3 100644 (file)
@@ -128,6 +128,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>');
 
index 19c20be28e1fbe3dbc9add8307f28095302c3845..59f32d0a8168f49652449fb0e8ef70ca7fc0c640 100644 (file)
@@ -213,7 +213,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;
        }
 
        /**