-
packages/Webkul/Core/src/Traits/Sanitizer.php
Open in GitHubuse enshrined\svgSanitize\Sanitizer as MainSanitizer; use Illuminate\Support\Facades\Storage; trait Sanitizer { public $mimeTypes = [ 'image/svg', 'image/svg+xml', ]; public function sanitizeSVG($path, $mimeType) { if ($this->checkMimeType($mimeType)) { /* sanitizer instance */ $sanitizer = new MainSanitizer; /* grab svg file */ $dirtySVG = Storage::get($path); /* save sanitized svg */ Storage::put($path, $sanitizer->sanitize($dirtySVG)); } } public function checkMimeType($mimeType) { return in_array($mimeType, $this->mimeTypes); } }
-
packages/Webkul/Product/src/Repositories/SearchRepository.php
Open in GitHubuse Illuminate\Support\Facades\Storage; use Webkul\Core\Traits\Sanitizer; class SearchRepository extends ProductRepository { use Sanitizer; public function uploadSearchImage($data) { $path = request()->file('image')->store('product-search'); $this->sanitizeSVG($path, $data['image']->getMimeType()); return Storage::url($path); } }