Merge pull request #27680 from nextcloud/backport/27675/stable20

[stable20] Validate the theming color also on CLI
This commit is contained in:
John Molakvoæ 2021-06-28 07:43:06 +02:00 committed by GitHub
commit 45cea9f772
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 1 deletions

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

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