Skip to content
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

Picture: images with & in URL are broken #1314

Open
dos1 opened this issue May 1, 2024 · 0 comments
Open

Picture: images with & in URL are broken #1314

dos1 opened this issue May 1, 2024 · 0 comments
Assignees
Labels

Comments

@dos1
Copy link
Contributor

dos1 commented May 1, 2024

When a Picture tries to download an image sent as a plain link in a chat message, it gets a garbled URL that has its & characters replaced with &, leading to download failure and broken_image_filled being displayed instead of the linked image.

I haven't looked deep enough to know whether this fix is reasonable, but it does make things work:

diff --git a/app/widgets/Picture/Picture.php b/app/widgets/Picture/Picture.php
index 71047419c..512046389 100644
--- a/app/widgets/Picture/Picture.php
+++ b/app/widgets/Picture/Picture.php
@@ -10,7 +10,7 @@ class Picture extends Base
 
     public function display()
     {
-        $url = urldecode($this->get('url'));
+        $url = html_entity_decode(urldecode($this->get('url')));
         $parsedUrl = parse_url($url);
         if (
             is_array($parsedUrl)
@@ -27,7 +27,7 @@ class Picture extends Base
         $max = $headers["download_content_length"] > $this->compressLimit ? $this->compressLimit : $headers["download_content_length"];
 
         $ch = curl_init();
-        curl_setopt($ch, CURLOPT_URL, $this->get('url'));
+        curl_setopt($ch, CURLOPT_URL, $url);
         curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
         curl_setopt($ch, CURLOPT_HEADER, true);
         curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
@edhelas edhelas self-assigned this May 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

2 participants