aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoas Schilling <213943+nickvergessen@users.noreply.github.com>2024-05-16 11:18:05 +0200
committerGitHub <noreply@github.com>2024-05-16 11:18:05 +0200
commit7e1c30f82a63fbea8c269e0eec38291377f32604 (patch)
tree79382784102d2ab45129e80fbb7b51029b354ff0
parentef1c32a222c2f0fb490337f81680e88e8d0f85de (diff)
parent4286660983525bb9be46e5d84d9f0b87634df53c (diff)
downloadnextcloud-server-7e1c30f82a63fbea8c269e0eec38291377f32604.tar.gz
nextcloud-server-7e1c30f82a63fbea8c269e0eec38291377f32604.zip
Merge pull request #45340 from nextcloud/bugfix/noid/widen-svg-block
fix: Extend SVG reference check
-rw-r--r--lib/private/Preview/SVG.php2
-rw-r--r--tests/lib/Preview/SVGTest.php29
2 files changed, 30 insertions, 1 deletions
diff --git a/lib/private/Preview/SVG.php b/lib/private/Preview/SVG.php
index 207c9dfb021..0400038d980 100644
--- a/lib/private/Preview/SVG.php
+++ b/lib/private/Preview/SVG.php
@@ -50,7 +50,7 @@ class SVG extends ProviderV2 {
}
// Do not parse SVG files with references
- if (stripos($content, 'xlink:href') !== false) {
+ if (preg_match('/["\s](xlink:)?href\s*=/i', $content)) {
return null;
}
diff --git a/tests/lib/Preview/SVGTest.php b/tests/lib/Preview/SVGTest.php
index 8764f3a5a9f..6a0e93e5f79 100644
--- a/tests/lib/Preview/SVGTest.php
+++ b/tests/lib/Preview/SVGTest.php
@@ -29,4 +29,33 @@ class SVGTest extends Provider {
$this->markTestSkipped('No SVG provider present');
}
}
+
+ public function dataGetThumbnailSVGHref(): array {
+ return [
+ ['href'],
+ [' href'],
+ ["\nhref"],
+ ['xlink:href'],
+ [' xlink:href'],
+ ["\nxlink:href"],
+ ];
+ }
+
+ /**
+ * @dataProvider dataGetThumbnailSVGHref
+ * @requires extension imagick
+ */
+ public function testGetThumbnailSVGHref(string $content): void {
+ $handle = fopen('php://temp', 'w+');
+ fwrite($handle, '<svg viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg">
+ <image x="0" y="0"' . $content . '="fxlogo.png" height="100" width="100" />
+</svg>');
+ rewind($handle);
+
+ $file = $this->createMock(\OCP\Files\File::class);
+ $file->method('fopen')
+ ->willReturn($handle);
+
+ self::assertNull($this->provider->getThumbnail($file, 512, 512));
+ }
}