Merge pull request #27679 from nextcloud/backport/27675/stable21

[stable21] Validate the theming color also on CLI
pull/27703/head
John Molakvoæ 2021-06-28 07:43:09 +07:00 committed by GitHub
commit c4a20d3d5d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 1 deletions

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

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