Skip to content

Conversation

@der-eismann
Copy link

@der-eismann der-eismann commented Oct 10, 2024

First time contributor checklist:

Contributor checklist:

  • My contribution is not related to translations.
  • My commits are in nice logical chunks with good commit messages
  • My changes are rebased on the latest main branch
  • A npm run ready run passes successfully (more about tests here)
  • My changes are ready to be shipped to users

Description

Fixes #6645. As mentioned in the issue already, a lot of major CDNs (e.g. Amazon's CloudFront) omit the Content-Length header in some cases like when compression is enabled. This means that a lot of preview images cannot be loaded on desktop, but load without any issues on the mobile apps, which is confusing for users.

I changed the behavior to not fail when the header is missing. To still keep it safe I moved the Content-Type check in front of it and added a second one checking the actual size of the returned body before loading the image.

Tested with product pages of the shop I work with, previously the image wouldn't load at all, now it's displayed nicely in the chat. I also added a test to see if the second check was working as expected to still bail on huge images. I tested it on Fedora Linux 40 but no other devices.

screenshot-20241010-104432
(Hidden URLs since they are from an internal staging environment)

@der-eismann der-eismann marked this pull request as ready for review October 10, 2024 08:51
@ayumi-signal ayumi-signal self-assigned this Oct 10, 2024
@der-eismann
Copy link
Author

@ayumi-signal did you have a chance to take a look at this yet?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

og:image preview bails out if Content-Length header is missing, many image CDNs use streaming or chunked encoding now

3 participants