diff --git a/app/Services/BulkEventUploadCache.php b/app/Services/BulkEventUploadCache.php index 4b40447b4..10deb75a2 100644 --- a/app/Services/BulkEventUploadCache.php +++ b/app/Services/BulkEventUploadCache.php @@ -27,21 +27,33 @@ public static function key(string $token): string /** * Shared temp disk for validate → import. Never use `local` on deployed apps * (Forge may still set BULK_UPLOAD_TEMP_DISK=local from the old example). + * Also reject glued .env values like `localFACEBOOK_CLIENT_ID=…`. */ public static function tempDisk(?string $cachedDisk = null): string { $configured = (string) ($cachedDisk ?: config('filesystems.bulk_upload_temp_disk', 's3')); $cloud = (string) config('filesystems.cloud', 's3'); + $disks = config('filesystems.disks', []); if (app()->environment('local', 'testing')) { return $configured !== '' ? $configured : 'local'; } - if ($configured === '' || $configured === 'local') { - return $cloud !== '' ? $cloud : 's3'; + $usable = $configured !== '' + && $configured !== 'local' + && ! str_contains($configured, '=') + && is_array($disks) + && array_key_exists($configured, $disks); + + if ($usable) { + return $configured; + } + + if ($cloud !== '' && is_array($disks) && array_key_exists($cloud, $disks)) { + return $cloud; } - return $configured; + return 's3'; } /** diff --git a/tests/Unit/BulkEventUploadCacheTest.php b/tests/Unit/BulkEventUploadCacheTest.php index f9c82a9c7..27a8a92e4 100644 --- a/tests/Unit/BulkEventUploadCacheTest.php +++ b/tests/Unit/BulkEventUploadCacheTest.php @@ -43,4 +43,20 @@ public function test_temp_disk_rejects_local_outside_local_environment(): void $this->assertSame('s3', BulkEventUploadCache::tempDisk('local')); $this->assertSame('s3', BulkEventUploadCache::tempDisk('s3')); } + + public function test_temp_disk_rejects_glued_env_disk_name(): void + { + config([ + 'filesystems.bulk_upload_temp_disk' => 'localFACEBOOK_CLIENT_ID=138145760054704', + 'filesystems.cloud' => 's3', + 'app.env' => 'production', + ]); + app()->detectEnvironment(fn () => 'production'); + + $this->assertSame('s3', BulkEventUploadCache::tempDisk()); + $this->assertSame( + 's3', + BulkEventUploadCache::tempDisk('localFACEBOOK_CLIENT_ID=138145760054704') + ); + } }