Open Graph: og:description truncation can split an HTML entity, producing "&#8217" in share previews

Open Beginner friendly
#55,870 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
68/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
php, wordpress
Domain
backend, web-dev

Research direction

Find the code that truncates Jetpack’s og:description to 197 characters and inspect how it handles entities produced by wptexturize(). Start with the Open Graph tag generation path and its tests; add a regression case where truncation lands inside an entity. Done when the generated meta description preserves the apostrophe or quote and the focused test passes.

Written by the indexing model from the issue text.

Description

Bug Needs triage
Impacted plugin

Jetpack

Quick summary

When Jetpack truncates og:description to 197 characters, the cut can land in the middle of an HTML
entity created by wptexturize() (e.g. "’" for an apostrophe). esc_attr() then escapes the broken
entity, so share previews show a literal "&#8217" in the text.

Steps to reproduce
  1. On a site with Jetpack's Open Graph tags enabled, create a post with no manual excerpt.
  2. Write the opening paragraph so an apostrophe (or a curly quote or dash) falls right around the 197th
    character, e.g. "...Most recently I've had all my domains through Namecheap. I've never used any of
    Namecheap's other services, though..."
  3. Publish the post and view the page source.
  4. Look at the og:description meta tag. It ends with "Namecheap&#8217…" instead of "Namecheap’s…".
  5. Optionally, share the post URL on Mastodon, iMessage or Slack: the preview shows a literal "&#8217"
    in the text.

Mine is a live example: https://initialcharge.net/2026/11/namecheap-to-porkbun/

Site owner impact

Fewer than 20% of the total website/platform users

Severity

Minor

What other impact(s) does this issue have?

No revenue impact

If a workaround is available, please outline it here.

Two options:

  1. Write a manual excerpt for the affected post. Make it short enough not to be truncated (under 197
    characters), or check that no apostrophe, curly quote or dash sits at the cut point.

  2. Remove the partial entity with the jetpack_open_graph_tags filter, which runs after the truncation:

add_filter( 'jetpack_open_graph_tags', function ( $tags ) {
if ( ! empty( $tags['og:description'] ) ) {
// Drop a half-cut entity (e.g. "&#8217") left right before the trailing ellipsis.
$tags['og:description'] = preg_replace( '/&#?[a-z0-9]*…$/i', '…',
$tags['og:description'] );
}
return $tags;
} );

Platform (Simple and/or Atomic)

Self-hosted

Dominant language
PHP
Stars
1.9k
Forks
913
Avg merge
1d 18h
Merged PRs (30d)
809

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from Automattic/jetpack

All issues in Automattic/jetpack

Similar issues

More PHP issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.