Validate the theming color also on CLI

Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
Joas Schilling 2021-06-25 16:58:29 +02:00
parent 00edbc2adf
commit 080e26fb80
No known key found for this signature in database
GPG key ID: 7076EA9751AACDDA
2 changed files with 10 additions and 1 deletions

View file

@ -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>');

View file

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