m3 Security Fixes
This commit is contained in:
@@ -10,9 +10,11 @@ use Symfony\Component\HttpFoundation\BinaryFileResponse;
|
||||
|
||||
class SpreadsheetExport
|
||||
{
|
||||
private const EXPORT_DIRECTORY = 'app/m3-exports/';
|
||||
|
||||
public function download(Collection $rows, string $filename): BinaryFileResponse
|
||||
{
|
||||
$path = storage_path('app/m3-exports/' . uniqid('', true) . '-' . basename($filename));
|
||||
$path = storage_path(self::EXPORT_DIRECTORY . uniqid('', true) . '-' . basename($filename));
|
||||
$this->write($rows, $path);
|
||||
|
||||
return response()->download($path, basename($filename))->deleteFileAfterSend(true);
|
||||
@@ -20,7 +22,7 @@ class SpreadsheetExport
|
||||
|
||||
public function store(Collection $rows, string $filename, ?string $disk = null): string
|
||||
{
|
||||
$tmp = storage_path('app/m3-exports/' . uniqid('', true) . '-' . basename($filename));
|
||||
$tmp = storage_path(self::EXPORT_DIRECTORY . uniqid('', true) . '-' . basename($filename));
|
||||
$this->write($rows, $tmp);
|
||||
|
||||
if ($disk && config("filesystems.disks.$disk")) {
|
||||
@@ -45,7 +47,7 @@ class SpreadsheetExport
|
||||
$sheet->fromArray($array->map(fn ($row) => array_values($row))->all(), null, 'A1');
|
||||
}
|
||||
}
|
||||
$tmp = storage_path('app/m3-exports/' . uniqid('', true) . '-' . basename($filename));
|
||||
$tmp = storage_path(self::EXPORT_DIRECTORY . uniqid('', true) . '-' . basename($filename));
|
||||
if (! is_dir(dirname($tmp))) {
|
||||
mkdir(dirname($tmp), 0775, true);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user