From 9e5885963c5dc09c20183732f0f94ca01598530e Mon Sep 17 00:00:00 2001 From: "John Molakvoæ (skjnldsv)" Date: Wed, 4 Jul 2018 10:04:38 +0200 Subject: Fixed icons detection and caching MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: John Molakvoæ (skjnldsv) --- lib/private/Group/Group.php | 2 +- lib/private/Template/IconsCacher.php | 18 +++++++++++++----- 2 files changed, 14 insertions(+), 6 deletions(-) (limited to 'lib') diff --git a/lib/private/Group/Group.php b/lib/private/Group/Group.php index 7f114873995..0d54cf8e35a 100644 --- a/lib/private/Group/Group.php +++ b/lib/private/Group/Group.php @@ -90,7 +90,7 @@ class Group implements IGroup { public function getDisplayName() { if (is_null($this->displayName)) { - return $this->gid.'-name'; + return $this->gid; } return $this->displayName; } diff --git a/lib/private/Template/IconsCacher.php b/lib/private/Template/IconsCacher.php index 3f405cbf3c1..79c4b9d8ec0 100644 --- a/lib/private/Template/IconsCacher.php +++ b/lib/private/Template/IconsCacher.php @@ -45,7 +45,7 @@ class IconsCacher { protected $urlGenerator; /** @var string */ - private $iconVarRE = '/--([a-z-]+): url\("([a-z0-9-\/]+)[^;]+;/m'; + private $iconVarRE = '/--([a-z0-9-]+): url\(["\']([a-z0-9-\/]+)[^;]+;/m'; /** @var string */ private $fileName = 'icons-vars.css'; @@ -84,12 +84,17 @@ class IconsCacher { * @param string $css */ public function setIconsCss(string $css) { + try { - $data = $this->folder->getFile($this->fileName)->getContent(); + $currentData = $this->folder->getFile($this->fileName)->getContent(); } catch (NotFoundException $e) { - $data = ''; + $currentData = ''; } - $icons = $this->getIconsFromCss($data . $css); + + // remove :root + $currentData = str_replace([':root {', '}'], '', $currentData); + + $icons = $this->getIconsFromCss($currentData . $css); $data = ''; foreach ($icons as $icon => $url) { @@ -127,7 +132,10 @@ class IconsCacher { public function injectCss() { // Only inject once foreach (\OC_Util::$headers as $header) { - if (strpos($header['attributes']['href'], $this->fileName) !== false) { + if ( + array_key_exists('attributes', $header) && + array_key_exists('href', $header['attributes']) && + strpos($header['attributes']['href'], $this->fileName) !== false) { return; } } -- cgit v1.2.3