Skip to content

Commit 837eb45

Browse files
committed
fix(theming): Stop leaking user theme into capabilities
Signed-off-by: jld3103 <jld3103yt@gmail.com>
1 parent 73a6061 commit 837eb45

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

apps/theming/lib/Capabilities.php

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,23 +86,26 @@ public function __construct(ThemingDefaults $theming, Util $util, IURLGenerator
8686
* }
8787
*/
8888
public function getCapabilities() {
89+
$color = $this->theming->getDefaultColorPrimary();
90+
$colorText = $this->theming->getDefaultTextColorPrimary();
91+
8992
$backgroundLogo = $this->config->getAppValue('theming', 'backgroundMime', '');
90-
$color = $this->theming->getColorPrimary();
93+
$backgroundPlain = $backgroundLogo === 'backgroundColor' || ($backgroundLogo === '' && $color !== '#0082c9');
94+
$background = $backgroundPlain ? $color : $this->url->getAbsoluteURL($this->theming->getBackground());
95+
9196
return [
9297
'theming' => [
9398
'name' => $this->theming->getName(),
9499
'url' => $this->theming->getBaseUrl(),
95100
'slogan' => $this->theming->getSlogan(),
96101
'color' => $color,
97-
'color-text' => $this->theming->getTextColorPrimary(),
102+
'color-text' => $colorText,
98103
'color-element' => $this->util->elementColor($color),
99104
'color-element-bright' => $this->util->elementColor($color),
100105
'color-element-dark' => $this->util->elementColor($color, false),
101106
'logo' => $this->url->getAbsoluteURL($this->theming->getLogo()),
102-
'background' => $backgroundLogo === 'backgroundColor' || ($backgroundLogo === '' && $this->theming->getColorPrimary() !== '#0082c9') ?
103-
$this->theming->getColorPrimary() :
104-
$this->url->getAbsoluteURL($this->theming->getBackground()),
105-
'background-plain' => $backgroundLogo === 'backgroundColor' || ($backgroundLogo === '' && $this->theming->getColorPrimary() !== '#0082c9'),
107+
'background' => $background,
108+
'background-plain' => $backgroundPlain,
106109
'background-default' => !$this->util->isBackgroundThemed(),
107110
'logoheader' => $this->url->getAbsoluteURL($this->theming->getLogo()),
108111
'favicon' => $this->url->getAbsoluteURL($this->theming->getLogo()),

apps/theming/tests/CapabilitiesTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,13 +165,13 @@ public function testGetCapabilities($name, $url, $slogan, $color, $textColor, $l
165165
->method('getSlogan')
166166
->willReturn($slogan);
167167
$this->theming->expects($this->atLeast(1))
168-
->method('getColorPrimary')
168+
->method('getDefaultColorPrimary')
169169
->willReturn($color);
170170
$this->theming->expects($this->exactly(3))
171171
->method('getLogo')
172172
->willReturn($logo);
173173
$this->theming->expects($this->once())
174-
->method('getTextColorPrimary')
174+
->method('getDefaultTextColorPrimary')
175175
->willReturn($textColor);
176176

177177
$util = new Util($this->config, $this->createMock(IAppManager::class), $this->createMock(IAppData::class), $this->createMock(ImageManager::class));

0 commit comments

Comments
 (0)