aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2018-10-25 16:04:23 +0200
committerGitHub <noreply@github.com>2018-10-25 16:04:23 +0200
commit6ad7f329385f73a731f69d9f00cf5b038f3eac04 (patch)
treec85fa80469f653b4a9390ae8ea4a0dc3f699ea5b /core
parent0a2476fcb3823864bceb116d79d48a8278ea4981 (diff)
parentd21ded67a70672cfa56a48051fa752b431118604 (diff)
downloadnextcloud-server-6ad7f329385f73a731f69d9f00cf5b038f3eac04.tar.gz
nextcloud-server-6ad7f329385f73a731f69d9f00cf5b038f3eac04.zip
Merge pull request #12016 from nextcloud/wip/noid/icon-base64
Directly embed icons into the icon-vars css file
Diffstat (limited to 'core')
-rw-r--r--core/Controller/SvgController.php18
1 files changed, 9 insertions, 9 deletions
diff --git a/core/Controller/SvgController.php b/core/Controller/SvgController.php
index f7159dd9fe1..bbf4e61c60c 100644
--- a/core/Controller/SvgController.php
+++ b/core/Controller/SvgController.php
@@ -31,6 +31,7 @@ use OCP\AppFramework\Http\NotFoundResponse;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\App\IAppManager;
use OCP\IRequest;
+use OC\Template\IconsCacher;
class SvgController extends Controller {
@@ -43,15 +44,20 @@ class SvgController extends Controller {
/** @var IAppManager */
protected $appManager;
+ /** @var IconsCacher */
+ private $iconsCacher;
+
public function __construct(string $appName,
IRequest $request,
ITimeFactory $timeFactory,
- IAppManager $appManager) {
+ IAppManager $appManager,
+ IconsCacher $iconsCacher) {
parent::__construct($appName, $request);
$this->serverRoot = \OC::$SERVERROOT;
$this->timeFactory = $timeFactory;
$this->appManager = $appManager;
+ $this->iconsCacher = $iconsCacher;
}
/**
@@ -114,17 +120,11 @@ class SvgController extends Controller {
$svg = file_get_contents($path);
- if (is_null($svg)) {
+ if ($svg === null) {
return new NotFoundResponse();
}
- // add fill (fill is not present on black elements)
- $fillRe = '/<((circle|rect|path)((?!fill)[a-z0-9 =".\-#():;])+)\/>/mi';
- $svg = preg_replace($fillRe, '<$1 fill="#' . $color . '"/>', $svg);
-
- // replace any fill or stroke colors
- $svg = preg_replace('/stroke="#([a-z0-9]{3,6})"/mi', 'stroke="#' . $color . '"', $svg);
- $svg = preg_replace('/fill="#([a-z0-9]{3,6})"/mi', 'fill="#' . $color . '"', $svg);
+ $svg = $this->iconsCacher->colorizeSvg($svg, $color);
$response = new DataDisplayResponse($svg, Http::STATUS_OK, ['Content-Type' => 'image/svg+xml']);