X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/5d2aad6a9e0675dc10c187c8c6c90294f47f22f7..refs/pull/4467/head:/app/Uploads/AttachmentService.php diff --git a/app/Uploads/AttachmentService.php b/app/Uploads/AttachmentService.php index 9d1f96ae4..ddabec09f 100644 --- a/app/Uploads/AttachmentService.php +++ b/app/Uploads/AttachmentService.php @@ -9,7 +9,7 @@ use Illuminate\Contracts\Filesystem\Filesystem as Storage; use Illuminate\Filesystem\FilesystemManager; use Illuminate\Support\Facades\Log; use Illuminate\Support\Str; -use League\Flysystem\Util; +use League\Flysystem\WhitespacePathNormalizer; use Symfony\Component\HttpFoundation\File\UploadedFile; class AttachmentService @@ -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') { + if ($storageType === 'local' || $storageType === 'local_secure' || $storageType === 'local_secure_restricted') { $storageType = 'local_secure_attachments'; } @@ -54,7 +54,7 @@ class AttachmentService */ protected function adjustPathForStorageDisk(string $path): string { - $path = Util::normalizePath(str_replace('uploads/files/', '', $path)); + $path = (new WhitespacePathNormalizer())->normalizePath(str_replace('uploads/files/', '', $path)); if ($this->getStorageDiskName() === 'local_secure_attachments') { return $path; @@ -63,16 +63,6 @@ class AttachmentService return 'uploads/files/' . $path; } - /** - * Get an attachment from storage. - * - * @throws FileNotFoundException - */ - public function getAttachmentFromStorage(Attachment $attachment): string - { - return $this->getStorageDisk()->get($this->adjustPathForStorageDisk($attachment->path)); - } - /** * Stream an attachment from storage. *