thephpleague / glide

Wonderfully easy on-demand image manipulation library with an HTTP based API.
http://glide.thephpleague.com
MIT License
2.55k stars 198 forks source link

Special characters on file name breaking UrlBuilder->getUrl #276

Open luizgaroland opened 4 years ago

luizgaroland commented 4 years ago

Currently im having a problem with the UrlBuilder.

UrlBuilder->getUrl uses parse_url and it return the wrong path for my files if they have a special character on the name.

For example Se#ection_188.png becomes '/path/Se' and it causes a failure.

To fix this i did something like this just before the parse_url:

$pathinfo = pathinfo($path);
$encodedFileName = urlencode($pathinfo['basename']);
$pathinfo['dirname'] = implode('/', array_map(function ($element) {
    return urlencode($element);
}, explode('/', $pathinfo['dirname'])));
$path = $pathinfo['dirname'] . '/' . $encodedFileName;

And then decoded the path inside the request controller.

Is there a way to achieve this without having to edit the the UrlBuilder directly?