You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I encountered a special case, where images won't load, if the base64-encoded path of the generated Glide image URL contains multiple strings, like in /img/asset/YXNzZXRzLzgwMF/DvGJlci11bnMvbWEtZm90by12b24tb2Jlbl8yMDE3LmpwZw==/ma-foto-von-oben_2017.jpg.
This URL is technically correct, but Laravel somehow doesn't use the correct portion of the URL to decode the base64 part. Laravel ends up only decoding YXNzZXRzLzgwMF, but not the whole YXNzZXRzLzgwMF/DvGJlci11bnMvbWEtZm90by12b24tb2Jlbl8yMDE3LmpwZw== string. The whole string would result in the decoded string 800_über-uns/ma-foto-von-oben_2017.jpg.
I know, that Statamic converts german Umlaute to usual characters, but this came from an older project. It is only an example to demonstrate the issue with the special base64 string. The problematic base64 string can be generated from other values as well.
I made a fix in the GlideController which solves this issue (although it doesn't seem like the best solution to me):
Create a new folder from a CLI under public/assets named 800_über-uns (need to use CLI because in newer versions Statamic would convert an ü to u
Upload an image to that folder called ma-foto-von-oben_2017.jpg (the naming here is only important to make sure, that the generated base64 string contains multiple /)
Edit resources/views/home.antlers.html and insert this line: <img src="{{ glide:image }}" /
The image cannot be loaded, because the servers returns a 404 error.
Yea, I tried to use the encoded version %2F for the slash, but it didn't help.
I also thought about this and it seems like a doable workaround to me, although it might break some images at first, as long as the static cache is not cleared.
Would you implement these functions as a global helper (in src/Support/Str.php) or only use its logic within the necessary places (GlideUrlBuilder and GlideController)?
It also seems to me, that this code is fine as well (without the padding):
Bug description
I encountered a special case, where images won't load, if the base64-encoded path of the generated Glide image URL contains multiple strings, like in
/img/asset/YXNzZXRzLzgwMF/DvGJlci11bnMvbWEtZm90by12b24tb2Jlbl8yMDE3LmpwZw==/ma-foto-von-oben_2017.jpg
.This URL is technically correct, but Laravel somehow doesn't use the correct portion of the URL to decode the base64 part. Laravel ends up only decoding
YXNzZXRzLzgwMF
, but not the wholeYXNzZXRzLzgwMF/DvGJlci11bnMvbWEtZm90by12b24tb2Jlbl8yMDE3LmpwZw==
string. The whole string would result in the decoded string800_über-uns/ma-foto-von-oben_2017.jpg
.I know, that Statamic converts german Umlaute to usual characters, but this came from an older project. It is only an example to demonstrate the issue with the special base64 string. The problematic base64 string can be generated from other values as well.
I made a fix in the
GlideController
which solves this issue (although it doesn't seem like the best solution to me):There is also a Laravel issue (laravel/framework#22125) which makes me think, that this is not possible to get fixed from Laravels side.
How to reproduce
image
public/assets
named800_über-uns
(need to use CLI because in newer versions Statamic would convert anü
tou
ma-foto-von-oben_2017.jpg
(the naming here is only important to make sure, that the generated base64 string contains multiple/
)resources/views/home.antlers.html
and insert this line:<img src="{{ glide:image }}" /
404
error.Another way is to clone https://github.com/morhi/statamic-glide-base64-path-bug
Logs
No response
Environment
Installation
Other (please explain)
Additional details
No response
The text was updated successfully, but these errors were encountered: