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

Load og:image preview even if Content-Length header is missing #7046

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants