Zeige Kurse im Mitgliederbereich und mach hochgeladene Fassungen ansehbar.
Deploy Test / test (push) Successful in 14s
Deploy Test / deploy (push) Successful in 22s

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
LarsandCursor committed 2026-11-15 10:27:20 +01:00
1 parent b374335b3a
commit 4f2e5a5f3b
24 files changed
+413 -47

No files matched your search

+29 -3
View File
@@ -29,16 +29,20 @@ public function handle(): void
return;
}
$name = basename($this->source);
$targetName = $this->storedName(basename($this->source));
if ($targetName === null) {
$this->markFailed($version, 'Der Dateityp wird nicht übernommen.');
if (preg_match('/^[A-Za-z0-9._-]+$/', $name) !== 1) {
return;
}
$target = 'inhalte/'.$version->id.'/'.$name;
$target = 'inhalte/'.$version->id.'/'.$targetName;
$incoming = Storage::disk('cms_incoming');
if (! $incoming->exists($this->source)) {
$this->markFailed($version, 'Die hochgeladene Datei wurde nicht gefunden.');
return;
}
@@ -55,4 +59,26 @@ public function handle(): void
$version->status = ContentVersionStatus::Bereit;
$version->save();
}
private function storedName(string $name): ?string
{
$extension = strtolower(pathinfo($name, PATHINFO_EXTENSION));
$stem = preg_replace('/[^A-Za-z0-9_-]+/', '-', pathinfo($name, PATHINFO_FILENAME)) ?? '';
$stem = trim($stem, '-');
if (preg_match('/^[a-z0-9]{1,8}$/', $extension) !== 1) {
return null;
}
return ($stem !== '' ? $stem : 'datei').'.'.$extension;
}
private function markFailed(ContentElementVersion $version, string $reason): void
{
$metadata = $version->metadata ?? [];
unset($metadata['incoming']);
$metadata['error'] = $reason;
$version->metadata = $metadata;
$version->save();
}
}