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

Aperta Adatta ai principianti
#55,870 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
68/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
php, wordpress
Ambito
backend, web-dev

Direzione di ricerca

Trova il codice che tronca og:description di Jetpack a 197 caratteri ed esamina come gestisce le entità prodotte da wptexturize(). Inizia dal percorso di generazione del tag Open Graph e dai relativi test; aggiungi un caso di regressione in cui il troncamento cade all’interno di un’entità. Il lavoro è completato quando la meta description generata conserva l’apostrofo o la virgoletta e il test mirato passa.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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

Lingua principale
PHP
Stelle
1.9k
Fork
913
Merge medio
1g 18h
PR unite (30g)
809

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di Automattic/jetpack

Tutte le issue di Automattic/jetpack

Issue simili

Altre issue su PHP

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.