Skip to content

Commit 3a44ca6

Browse files
authored
Merge pull request #27675 from nextcloud/bugfix/noid/fix-setting-theming-color
Validate the theming color also on CLI
2 parents 00edbc2 + 080e26f commit 3a44ca6

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

apps/theming/lib/Command/UpdateConfig.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,11 @@ protected function execute(InputInterface $input, OutputInterface $output): int
127127
$key = $key . 'Mime';
128128
}
129129

130+
if ($key === 'color' && !preg_match('/^\#([0-9a-f]{3}|[0-9a-f]{6})$/i', $value)) {
131+
$output->writeln('<error>The given color is invalid: ' . $value . '</error>');
132+
return 1;
133+
}
134+
130135
$this->themingDefaults->set($key, $value);
131136
$output->writeln('<info>Updated ' . $key . ' to ' . $value . '</info>');
132137

apps/theming/lib/ThemingDefaults.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,11 @@ public function getShortFooter() {
220220
* @return string
221221
*/
222222
public function getColorPrimary() {
223-
return $this->config->getAppValue('theming', 'color', $this->color);
223+
$color = $this->config->getAppValue('theming', 'color', $this->color);
224+
if (!preg_match('/^\#([0-9a-f]{3}|[0-9a-f]{6})$/i', $color)) {
225+
$color = '#0082c9';
226+
}
227+
return $color;
224228
}
225229

226230
/**

0 commit comments

Comments
 (0)