]> source.dussan.org Git - nextcloud-server.git/commitdiff
Validate the theming color also on CLI 27679/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:20:32 +0000 (16:20 +0000)
Signed-off-by: Joas Schilling <coding@schilljs.com>
apps/theming/lib/Command/UpdateConfig.php
apps/theming/lib/ThemingDefaults.php

index 001bc2d2d76aae3f1e1ad4fef5655c1bf92dc7c3..e790766cf71530c020d756972a48b73526dd6f39 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 35ed32c69a306193b4f643b3c1fa07b19185eee5..cf6df93255687d2073dd61d3c05af0919bcebad7 100644 (file)
@@ -214,7 +214,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;
        }
 
        /**