diff --git a/classes/SocialService.php b/classes/SocialService.php index 455c3bb..4fb5268 100644 --- a/classes/SocialService.php +++ b/classes/SocialService.php @@ -6,6 +6,7 @@ use Event; use Generator; use Illuminate\Support\Collection; use Media\Classes\MediaLibrary; +use Zoomyboy\Social\Exceptions\SocialException; use Zoomyboy\Social\Models\Page; use Zoomyboy\Social\Models\Setting; @@ -67,6 +68,11 @@ abstract class SocialService { public function saveUrl(string $source, ?string $filename = null): string { $filename = $filename ?: pathinfo(parse_url($source, PHP_URL_PATH), PATHINFO_BASENAME); + + if (!pathinfo($filename, PATHINFO_FILENAME)) { + throw new SocialException('No real filename for storage given in "'.$source.'"'); + } + $file = $this->page->mediaPath.$filename; if (!$this->media->exists($file)) { diff --git a/composer.json b/composer.json index 85c4a4b..539793e 100644 --- a/composer.json +++ b/composer.json @@ -8,5 +8,10 @@ "name": "Philipp Lang", "email": "philipp.lang@dpsg-koeln.de" } - ] + ], + "autoload": { + "psr-4": { + "Aweos\\Social\\Exceptions\\": "./exceptions" + } + } } diff --git a/exceptions/SocialException.php b/exceptions/SocialException.php new file mode 100644 index 0000000..6c23119 --- /dev/null +++ b/exceptions/SocialException.php @@ -0,0 +1,9 @@ +