Fix icon cacher url matching

Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
Julius Härtl 2018-10-29 12:09:30 +01:00
parent 5c74423902
commit aec0a6c096
No known key found for this signature in database
GPG key ID: 4C614C6ED2CDE6DF

View file

@ -47,7 +47,7 @@ class IconsCacher {
protected $urlGenerator;
/** @var string */
private $iconVarRE = '/--(icon-[a-zA-Z0-9-]+):\s?url\(["\']?([a-zA-Z0-9-_\~\/\.\?\=\:\;\+\,]+)[^;]+;/m';
private $iconVarRE = '/--(icon-[a-zA-Z0-9-]+):\s?url\(["\']?([a-zA-Z0-9-_\~\/\.\?\&\=\:\;\+\,]+)[^;]+;/m';
/** @var string */
private $fileName = 'icons-vars.css';
@ -142,21 +142,20 @@ class IconsCacher {
$base = $this->getRoutePrefix() . '/svg/';
$cleanUrl = \substr($url, \strlen($base));
if (\strpos($url, $base . 'core') === 0) {
$cleanUrl = \substr($cleanUrl, \strlen('core'), \strpos($cleanUrl, '?')-\strlen('core'));
$parts = \explode('/', $cleanUrl);
$color = \array_pop($parts);
$cleanUrl = \implode('/', $parts);
$location = \OC::$SERVERROOT . '/core/img/' . $cleanUrl . '.svg';
} elseif (\strpos($url, $base) === 0) {
$cleanUrl = \substr($cleanUrl, 0, \strpos($cleanUrl, '?'));
$parts = \explode('/', $cleanUrl);
$app = \array_shift($parts);
$color = \array_pop($parts);
$cleanUrl = \implode('/', $parts);
$location = \OC_App::getAppPath($app) . '/img/' . $cleanUrl . '.svg';
if ($app === 'settings') {
$location = \OC::$SERVERROOT . '/settings/img/' . $cleanUrl . '.svg';
$cleanUrl = \substr($cleanUrl, \strlen('core'));
if (\preg_match('/\/([a-zA-Z0-9-_\~\/\.\=\:\;\+\,]+)\?color=([0-9a-fA-F]{3,6})/', $cleanUrl, $matches)) {
list(,$cleanUrl,$color) = $matches;
$location = \OC::$SERVERROOT . '/core/img/' . $cleanUrl . '.svg';
}
} elseif (\strpos($url, $base) === 0) {
if(\preg_match('/([A-z0-9\_\-]+)\/([a-zA-Z0-9-_\~\/\.\=\:\;\+\,]+)\?color=([0-9a-fA-F]{3,6})/', $cleanUrl, $matches)) {
list(,$app,$cleanUrl, $color) = $matches;
$location = \OC_App::getAppPath($app) . '/img/' . $cleanUrl . '.svg';
if ($app === 'settings') {
$location = \OC::$SERVERROOT . '/settings/img/' . $cleanUrl . '.svg';
}
}
}
return [
$location,