Skip to content

Commit 004233f

Browse files
committed
fix: SVG check
1 parent 8e1e957 commit 004233f

File tree

1 file changed

+4
-12
lines changed

1 file changed

+4
-12
lines changed

src/Services/Assets/Components/ComponentVectorImage.php

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -70,23 +70,15 @@ public function save()
7070
if (request()->hasFile($fileId)) {
7171
$file = request()->file($fileId);
7272
if (! $file->isValid()) {
73-
$errorResponse = new LayoutResponse;
73+
abort(500, 'SVG file is not valid');
7474

75-
$errorResponse->addAction(new Toast($file->getErrorMessage(), 'error'));
76-
77-
return $errorResponse->build();
7875
}
7976
}
8077

8178
$sanitizer = new Sanitizer;
82-
$cleanSVG = $sanitizer->sanitize($file);
83-
84-
if (! $cleanSVG) {
85-
$errorResponse = new LayoutResponse;
86-
87-
$errorResponse->addAction(new Toast('SVG could not be sanitized', 'error'));
88-
89-
return $errorResponse->build();
79+
$cleanSVG = $sanitizer->sanitize(file_get_contents($file->path()));
80+
if ($cleanSVG === false) {
81+
abort(500, 'SVG could not be sanitized');
9082
}
9183

9284
$filename = $this->recordId.'.svg';

0 commit comments

Comments
 (0)