From bedd500884aaef136089e857cd04c18a0fce8070 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 24 Apr 2017 12:15:28 +0200 Subject: [PATCH] Logo and background URLs must be relative They are used way to often for such a change Signed-off-by: Joas Schilling --- apps/theming/lib/ThemingDefaults.php | 10 +++++----- apps/theming/tests/ThemingDefaultsTest.php | 9 +++------ 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/apps/theming/lib/ThemingDefaults.php b/apps/theming/lib/ThemingDefaults.php index 319474a8552..85ad11943dd 100644 --- a/apps/theming/lib/ThemingDefaults.php +++ b/apps/theming/lib/ThemingDefaults.php @@ -144,10 +144,10 @@ class ThemingDefaults extends \OC_Defaults { $cacheBusterCounter = $this->config->getAppValue('theming', 'cachebuster', '0'); if(!$logo || !$logoExists) { - return $this->urlGenerator->getAbsoluteURL($this->urlGenerator->imagePath('core','logo.svg') . '?v=' . $cacheBusterCounter); + return $this->urlGenerator->imagePath('core','logo.svg') . '?v=' . $cacheBusterCounter; } - return $this->urlGenerator->linkToRouteAbsolute('theming.Theming.getLogo') . '?v=' . $cacheBusterCounter; + return $this->urlGenerator->linkToRoute('theming.Theming.getLogo') . '?v=' . $cacheBusterCounter; } /** @@ -169,7 +169,7 @@ class ThemingDefaults extends \OC_Defaults { return $this->urlGenerator->imagePath('core','background.jpg'); } - return $this->urlGenerator->linkToRouteAbsolute('theming.Theming.getLoginBackground'); + return $this->urlGenerator->linkToRoute('theming.Theming.getLoginBackground'); } @@ -186,8 +186,8 @@ class ThemingDefaults extends \OC_Defaults { 'theming-cachebuster' => "'" . $this->config->getAppValue('theming', 'cachebuster', '0') . "'", ]; - $variables['image-logo'] = "'".$this->getLogo()."'"; - $variables['image-login-background'] = "'".$this->getBackground()."'"; + $variables['image-logo'] = "'".$this->urlGenerator->getAbsoluteURL($this->getLogo())."'"; + $variables['image-login-background'] = "'".$this->urlGenerator->getAbsoluteURL($this->getBackground())."'"; if ($this->config->getAppValue('theming', 'color', null) !== null) { if ($this->util->invertTextColor($this->getColorPrimary())) { diff --git a/apps/theming/tests/ThemingDefaultsTest.php b/apps/theming/tests/ThemingDefaultsTest.php index 2fda63d4fe1..0334f5ba69c 100644 --- a/apps/theming/tests/ThemingDefaultsTest.php +++ b/apps/theming/tests/ThemingDefaultsTest.php @@ -432,8 +432,7 @@ class ThemingDefaultsTest extends TestCase { ->method('getAppValue') ->with('theming', 'backgroundMime', false) ->willReturn('image/svg+xml'); - $expected = $this->urlGenerator->linkToRouteAbsolute('theming.Theming.getLoginBackground'); - $this->assertEquals($expected, $this->template->getBackground()); + $this->assertEquals('/index.php/apps/theming/loginbackground', $this->template->getBackground()); } public function testGetLogoDefault() { @@ -455,8 +454,7 @@ class ThemingDefaultsTest extends TestCase { ->method('getFolder') ->with('images') ->willThrowException(new \Exception()); - $expected = $this->urlGenerator->getAbsoluteURL('/core/img/logo.svg') . '?v=0'; - $this->assertEquals($expected, $this->template->getLogo()); + $this->assertEquals('/core/img/logo.svg?v=0', $this->template->getLogo()); } public function testGetLogoCustom() { @@ -478,8 +476,7 @@ class ThemingDefaultsTest extends TestCase { ->method('getAppValue') ->with('theming', 'cachebuster', '0') ->willReturn('0'); - $expected = $this->urlGenerator->getAbsoluteURL('index.php/apps/theming/logo') . '?v=0'; - $this->assertEquals($expected, $this->template->getLogo()); + $this->assertEquals('/index.php/apps/theming/logo?v=0', $this->template->getLogo()); } public function testGetScssVariablesCached() {