]> BookStack Code Mirror - bookstack/commitdiff
Fixed local_secure_restricted preventing attachment uploads 3693/head
authorDan Brown <redacted>
Fri, 2 Sep 2022 13:40:17 +0000 (14:40 +0100)
committerDan Brown <redacted>
Fri, 2 Sep 2022 13:40:17 +0000 (14:40 +0100)
Due to option name change and therefore lack of handling.
Added test case to cover.

app/Uploads/AttachmentService.php
tests/Uploads/AttachmentTest.php

index e46c2be4593edf70bc23929ef5e28f9b114d0956..88bb41efb0bcc614eaafa22ac421733446484383 100644 (file)
@@ -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';
         }
 
index 27a23bcaeed3d385ebce0dd27f31aa5f3ef12f5e..e71adf70b59ca984288babd45ba7e6809f92d452 100644 (file)
@@ -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();
+    }
 }