Skip to main content

Black Friday 2025! Only until December 1st: coupon FRIDAY25 for 40% off Yearly/Lifetime membership!

Read more here

unopim/unopim

7807 stars
2 code files
View unopim/unopim on GitHub

packages/Webkul/Core/src/Traits/Sanitizer.php

Open in GitHub
use 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 GitHub
use 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);
}
}

We'd Love Your Feedback

Tell us what you like or what we can improve

Feel free to share anything you like or dislike about this page or the platform in general.