Skip to content

NOW MANAGED ON CODEBERG

Fixed local_secure_restricted preventing attachment uploads

Dan Brownc76b5e2ec45c
diff --git a/app/Uploads/AttachmentService.php b/app/Uploads/AttachmentService.php
index e46c2be45..88bb41efb 100644
--- a/app/Uploads/AttachmentService.php
+++ b/app/Uploads/AttachmentService.php
@@ -41,7 +41,7 @@ class AttachmentService
// Change to our secure-attachment disk if any of the local options
// are used to prevent escaping that location.
- if ($storageType === 'local' || $storageType === 'local_secure' || $storageType === 'local_secure_with_permissions') {
+ if ($storageType === 'local' || $storageType === 'local_secure' || $storageType === 'local_secure_restricted') {
$storageType = 'local_secure_attachments';
}
diff --git a/tests/Uploads/AttachmentTest.php b/tests/Uploads/AttachmentTest.php
index 27a23bcae..e71adf70b 100644
--- a/tests/Uploads/AttachmentTest.php
+++ b/tests/Uploads/AttachmentTest.php
@@ -341,4 +341,19 @@ class AttachmentTest extends TestCase
$this->deleteUploads();
}
+
+ public function test_file_upload_works_when_local_secure_restricted_is_in_use()
+ {
+ config()->set('filesystems.attachments', 'local_secure_restricted');
+
+ $page = Page::query()->first();
+ $fileName = 'upload_test_file.txt';
+
+ $upload = $this->asAdmin()->uploadFile($fileName, $page->id);
+ $upload->assertStatus(200);
+
+ $attachment = Attachment::query()->orderBy('id', 'desc')->where('uploaded_to', '=', $page->id)->first();
+ $this->assertFileExists(storage_path($attachment->path));
+ $this->deleteUploads();
+ }
}