-
-
Notifications
You must be signed in to change notification settings - Fork 553
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Asset url encoding issues: spaces and accents #5593
Comments
It's the spaces in the
But if you get rid of the spaces How are you getting the URL? |
These spaces have been added to filenames by the client. The statamic asset url is returning this value ($asset_field->url). Of course I cannot stop my clients from adding spaces to filenames. Either the helper function, or the statamic asset object handled the spaces correctly in v3.2 because this problem has only presented in 3.3. |
Nah it should handle it automatically. I just wanted to confirm how you're getting the URL so we can address the right spot. |
In the meantime you could do |
Cheers. Thought I was going crazy for there for a minute. I'll do a str_replace for now. |
It seems it's not just spaces that are a problem. The accent in the filename below causes the same error. https://ams3.digitaloceanspaces.com/myspace/images/myfolder/Dún%20Laoghaire_18%202.jpg |
If you open that image through the DO Spaces UI... what does the URL look like? What does it do with the |
https://myspace.ams3.digitaloceanspaces.com/images/dun-laoghaire/D%C3%BAn%20Laoghaire_18%202.jpg I guess this is a ú: |
I ended up making a custom modifier to fix this:
|
@edalzell That works for me alright. No more issues with spaces or accents. Can we get this added to the 3.3 core? |
I don't want to add the modifier to the core, I'd rather just have it output the correct URL to begin with. |
Bug description
I think there is a problem with the Statamic\Support\Str::isUrl() helper, more details below.
I was using a piece of code to generate glide images in a blade component, which I used for complex responsive images. This code was taken directly from the old blade directives package:
This piece of code no longer works in Statamic 3.3 and I am getting this error:
"Call to a member function disk() on null"
I think I have found the problem in
statamic\cms\src\Tags\Glide.php
:The Str::isUrl() helper is failing for my digital ocean asset container urls. Example:
https://ams3.digitaloceanspaces.com/mywebsite/images/subfolder/Image X - Whatever_17.jpg
When this check fails the Glide class then tries to generateByAsset(), which then throws the disk() on null error.
I have tried manually calling Statamic\Support\Str::isUrl() on the url above and it does in fact return false - this should not happen right?
If I remove the isUrl check from Glide.php then everything works fine.
How to reproduce
Try to generate glide images using urls through a class or function.
Or simply call \Statamic\Support\Str::isUrl('https://ams3.digitaloceanspaces.com/mywebsite/images/subfolder/Image X - Whatever_17.jpg')
The above will return false when it should return true.
Logs
No response
Versions
Statamic 3.3.2 Pro
Laravel 9.5.1
PHP 8.0.10
statamic/seo-pro 3.1.0
Installation
Existing Laravel app
Antlers Parser
No response
Additional details
No response
The text was updated successfully, but these errors were encountered: