SVG;
beforeEach(function () {
Storage::fake();
$this->sanitizer = new class
{
use Sanitizer;
};
});
/**
* Store the payload the way the upload handlers do, then sanitize it.
*/
function storeThenSanitize(object $sanitizer, string $storedPath, string $clientName): string
{
Storage::put($storedPath, MALICIOUS_SVG);
$sanitizer->sanitizeSvg(
$storedPath,
UploadedFile::fake()->createWithContent($clientName, MALICIOUS_SVG)
);
return (string) Storage::get($storedPath);
}
it('sanitizes an svg uploaded under a non-svg name', function () {
$result = storeThenSanitize($this->sanitizer, 'tinymce/abc123.svg', 'payload.png');
expect($result)->not->toContain('