Automattic / Automattic/jetpack

Wrong OpenGraph Image URL Encoding of Non Latin Characters - In-Content Featured Image Only

Open
#38,975 5 comments 0 reactions 0 assignees View on GitHub
[Feature] Publicize [Feature] Sharing [Focus] i18n [Platform] Atomic [Plugin] Jetpack [Plugin] Social [Pri] Low Bug Customer Report [LEGACY] Triaged
Dominant language
PHP
Stars
1.8k
Forks
898
Avg merge
1d 18h
Merged PRs (30d)
774

Description

### Impacted plugin

Social

### Quick summary

If the featured image of a post is taken from the content (not set explicitly via the editor), and this image title contains non latin characters (Ё, ﺡ, Ω, ש, 日, न..) the URL used for OpenGraph image `og:image` gets encoded to Latin-1 but the file title keeps its UTF-8 encoding, resulting in a 404 and empty social media thumbnails.

The issue doesn't happen if the image is manually set as the featured image of the post - the `og:image` URL remains in UTF-8.

### Steps to reproduce

1. Make sure Jetpack Social is On (Jetpack > Settings > Sharing)
2. Create a new post
3. Take an image and change its title to something containing non-latin characters, like: `تجربه.png`
4. Add that image to the content of the post
5. Publish the post
6. Test by checking the HTML for og:image meta tag or by sharing the post.

### A clear and concise description of what you expected to happen.

The image URL encoding to remain as UTF-8 and to link to the uploaded image.

### What actually happened

The Encoding is changed to Latin-1 so the image URL becomes .../تجربه.png instead of .../تجربه.png

### Impact

Some (< 50%)

### Available workarounds?

Yes, easy to implement

### If the above answer is "Yes...", outline the workaround.

To rename all images used as thumbnails so they are in Latin characters
Or
To set a featured image manually on all posts
Or
Using a third-party tool to generate the social thumbnails like Yoast SEO

### Platform (Simple and/or Atomic)

Atomic, Self-hosted

### Logs or notes

It doesn't happen on Dotcom Simple sites because the image names are converted to Latin-1 then Hex on upload, affecting both the hosted file and the code.

8616758-zen

Contributor guide

Open the contributing guide

Research direction

No files or tests are named. Reproduce the issue with Jetpack Social using an in-content featured image named with non-Latin characters, then trace the generation of the og:image URL; done means the URL remains UTF-8 and resolves to the uploaded image.

Written by the indexing model from the issue text.

Assessment

Tech stack
php, wordpress
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.