aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoeland Jago Douma <rullzer@users.noreply.github.com>2019-06-25 22:04:12 +0200
committerGitHub <noreply@github.com>2019-06-25 22:04:12 +0200
commita47403d5f85b2ebe2fa14672181b8ce0b6122d34 (patch)
tree15165191ef732a7fcc6590ab0d99dc7bbb36933c
parentda025d4867cf8d54a1f2c7405dfb714093aa6989 (diff)
parent05381f00d25e380c557a3a1100dd83e75298f130 (diff)
downloadnextcloud-server-a47403d5f85b2ebe2fa14672181b8ce0b6122d34.tar.gz
nextcloud-server-a47403d5f85b2ebe2fa14672181b8ce0b6122d34.zip
Merge pull request #16021 from nextcloud/bugfix/noid/fall-back-to-black-for-non-color-values
Fall back to black for non-color values
-rw-r--r--core/Controller/SvgController.php1
-rw-r--r--lib/private/Template/IconsCacher.php5
2 files changed, 6 insertions, 0 deletions
diff --git a/core/Controller/SvgController.php b/core/Controller/SvgController.php
index bbf4e61c60c..b956f724ad8 100644
--- a/core/Controller/SvgController.php
+++ b/core/Controller/SvgController.php
@@ -111,6 +111,7 @@ class SvgController extends Controller {
*
* @param string $path
* @param string $color
+ * @param string $fileName
* @return DataDisplayResponse|NotFoundResponse
*/
private function getSvg(string $path, string $color, string $fileName) {
diff --git a/lib/private/Template/IconsCacher.php b/lib/private/Template/IconsCacher.php
index 9cd4f8bca10..dd83ce78775 100644
--- a/lib/private/Template/IconsCacher.php
+++ b/lib/private/Template/IconsCacher.php
@@ -184,6 +184,11 @@ class IconsCacher {
* @return string
*/
public function colorizeSvg($svg, $color): string {
+ if (!preg_match('/^[0-9a-f]{3,6}$/i', $color)) {
+ // Prevent not-sane colors from being written into the SVG
+ $color = '000';
+ }
+
// 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);