Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/Uploads/ImageRepo.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ public function updateImageDetails(Image $image, $updateDetails): Image
*/
public function updateImageFile(Image $image, UploadedFile $file): void
{
if ($file->getClientOriginalExtension() !== pathinfo($image->path, PATHINFO_EXTENSION)) {
if (strtolower($file->getClientOriginalExtension()) !== strtolower(pathinfo($image->path, PATHINFO_EXTENSION))) {
throw new ImageUploadException(trans('errors.image_upload_replace_type'));
}

Expand Down
27 changes: 27 additions & 0 deletions tests/Uploads/ImageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,33 @@ public function test_image_file_update()
$this->files->deleteAtRelativePath($relPath);
}

public function test_image_file_update_allows_case_differences()
{
$page = $this->entities->page();
$this->asEditor();

$imgDetails = $this->files->uploadGalleryImageToPage($this, $page);
$relPath = $imgDetails['path'];

$newUpload = $this->files->uploadedImage('updated-image.PNG', 'compressed.png');
$this->assertFileEquals($this->files->testFilePath('test-image.png'), public_path($relPath));

$imageId = $imgDetails['response']->id;
$image = Image::findOrFail($imageId);
$image->updated_at = now()->subMonth();
$image->save();

$this->call('PUT', "/images/{$imageId}/file", [], [], ['file' => $newUpload])
->assertOk();

$this->assertFileEquals($this->files->testFilePath('compressed.png'), public_path($relPath));

$image->refresh();
$this->assertTrue($image->updated_at->gt(now()->subMinute()));

$this->files->deleteAtRelativePath($relPath);
}

public function test_image_file_update_does_not_allow_change_in_image_extension()
{
$page = $this->entities->page();
Expand Down