diff --git a/app/Config/filesystems.php b/app/Config/filesystems.php index bd7d28300..30a5c5369 100644 --- a/app/Config/filesystems.php +++ b/app/Config/filesystems.php @@ -42,13 +42,6 @@ return [ 'root' => storage_path(), ], - 'ftp' => [ - 'driver' => 'ftp', - 'host' => 'ftp.example.com', - 'username' => 'your-username', - 'password' => 'your-password', - ], - 's3' => [ 'driver' => 's3', 'key' => env('STORAGE_S3_KEY', 'your-key'), @@ -59,16 +52,6 @@ return [ 'use_path_style_endpoint' => env('STORAGE_S3_ENDPOINT', null) !== null, ], - 'rackspace' => [ - 'driver' => 'rackspace', - 'username' => 'your-username', - 'key' => 'your-key', - 'container' => 'your-container', - 'endpoint' => 'https://identity.api.rackspacecloud.com/v2.0/', - 'region' => 'IAD', - 'url_type' => 'publicURL', - ], - ], ]; diff --git a/app/Uploads/ImageService.php b/app/Uploads/ImageService.php index 9d38b0b12..1e5ad8aa1 100644 --- a/app/Uploads/ImageService.php +++ b/app/Uploads/ImageService.php @@ -450,28 +450,32 @@ class ImageService /** * Get a storage path for the given image URL. + * Ensures the path will start with "uploads/images". * Returns null if the url cannot be resolved to a local URL. */ private function imageUrlToStoragePath(string $url): ?string { - $url = trim($url); + $url = ltrim(trim($url), '/'); // Handle potential relative paths $isRelative = strpos($url, 'http') !== 0; if ($isRelative) { - return trim($url, '/'); + if (strpos(strtolower($url), 'uploads/images') === 0) { + return trim($url, '/'); + } + return null; } // Handle local images based on paths on the same domain $potentialHostPaths = [ - url('/'), - $this->getPublicUrl('/'), + url('uploads/images/'), + $this->getPublicUrl('/uploads/images/'), ]; foreach ($potentialHostPaths as $potentialBasePath) { $potentialBasePath = strtolower($potentialBasePath); if (strpos(strtolower($url), $potentialBasePath) === 0) { - return trim(substr($url, strlen($potentialBasePath)), '/'); + return 'uploads/images/' . trim(substr($url, strlen($potentialBasePath)), '/'); } } diff --git a/tests/Entity/ExportTest.php b/tests/Entity/ExportTest.php index 5a94adac9..b1e6eb5fb 100644 --- a/tests/Entity/ExportTest.php +++ b/tests/Entity/ExportTest.php @@ -1,9 +1,8 @@ html = ''; + Storage::disk('local')->makeDirectory('uploads/images/gallery'); + Storage::disk('local')->put('uploads/images/gallery/svg_test.svg', ''); + $page->html = ''; $page->save(); $this->asEditor(); - $this->mockHttpFetch(''); $resp = $this->get($page->getUrl('/export/html')); + Storage::disk('local')->delete('uploads/images/gallery/svg_test.svg'); + $resp->assertStatus(200); $resp->assertSee('' + ."\n".'' + ."\n".''; + $storageDisk = Storage::disk('local'); + $storageDisk->makeDirectory('uploads/images/gallery'); + $storageDisk->put('uploads/images/gallery/svg_test.svg', 'good'); + $storageDisk->put('uploads/svg_test.svg', 'bad'); + $page->save(); + + $resp = $this->asEditor()->get($page->getUrl('/export/html')); + + $storageDisk->delete('uploads/images/gallery/svg_test.svg'); + $storageDisk->delete('uploads/svg_test.svg'); + + $resp->assertDontSee('http://localhost/uploads/images/gallery/svg_test.svg'); + $resp->assertSee('http://localhost/uploads/svg_test.svg'); + $resp->assertSee('src="/uploads/svg_test.svg"'); + } + } \ No newline at end of file