Fix issue where URLs generated by the ImageResizer were not correctly encoded.
Related https://github.com/laravel/framework/issues/34199
This commit is contained in:
parent
ce47c0248f
commit
2c4d3c9f98
|
|
@ -500,7 +500,10 @@ class ImageResizer
|
|||
$url = $resizedDisk->url($this->getPathToResizedImage());
|
||||
}
|
||||
|
||||
return $url;
|
||||
// Ensure that a properly encoded URL is returned
|
||||
$segments = explode('/', $url);
|
||||
$lastSegment = array_pop($segments);
|
||||
return implode('/', $segments) . '/' . rawurlencode(rawurldecode($lastSegment));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Binary file not shown.
|
After Width: | Height: | Size: 6.6 KiB |
|
|
@ -320,6 +320,21 @@ class ImageResizerTest extends PluginTestCase
|
|||
);
|
||||
}
|
||||
|
||||
public function testSpaceInFilename()
|
||||
{
|
||||
// Media URL with space
|
||||
$this->setUpStorage();
|
||||
$this->copyMedia();
|
||||
|
||||
$imageResizer = new ImageResizer(
|
||||
URL::to(MediaLibrary::url('october space.png')),
|
||||
100,
|
||||
100
|
||||
);
|
||||
|
||||
$this->assertStringContainsString('october%20space', $imageResizer->getResizedUrl(), 'Resized URLs are not properly URL encoded');
|
||||
}
|
||||
|
||||
protected function setUpStorage()
|
||||
{
|
||||
$this->app->useStoragePath(base_path('storage/temp'));
|
||||
|
|
|
|||
Loading…
Reference in New Issue