SocialLinksPattern drops list item text outside the links, and counts every mailto: as a social service

Aperta
#6,308 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à
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
52/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
php
Ambito
backend

Direzione di ricerca

Start by reading SocialLinksPattern, especially the list conversion, service() and isSocialCluster() paths; the issue names no file path or test. Reproduce with the Markdown or HTML reduction in the issue, then check cases with text beside links and lists containing only mailto: links. Done means those cases preserve list text and mail-only lists are not converted to social links.

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

Descrizione

Summary

When SocialLinksPattern accepts a ul/ol as a social cluster, it builds core/social-link blocks from the anchors and discards everything else in the list items. Any text beside the links is silently lost. And because service() returns mail for every mailto: URL, isSocialCluster() accepts any list of two or more items that each contain an email address.

Seen in php-transformer v0.27.0, through FormatBridge with Markdown input (GFM to HTML first). The result was real data loss in a knowledge base entry: a history list became two mail social links, and the history lines were gone.

Reduction

Markdown:

- <[email protected]>
- 16 Nov: replied <[email protected]>

or the equivalent HTML:

<ul>
<li><a href="mailto:[email protected]">[email protected]</a></li>
<li>16 Nov: replied <a href="mailto:[email protected]">[email protected]</a></li>
</ul>

Output (v0.27.0):

<!-- wp:social-links {"showLabels":true,"className":"blocks-engine-source-social-item-spacing"} -->
<ul class="wp-block-social-links has-visible-labels blocks-engine-source-social-item-spacing">
<!-- wp:social-link {"url":"mailto:[email protected]","service":"mail","label":"[email protected]"} /-->
<!-- wp:social-link {"url":"mailto:[email protected]","service":"mail","label":"[email protected]"} /-->
</ul>
<!-- /wp:social-links -->

The 16 Nov: replied text is gone. A list with social hosts behaves the same way (- Code on [GitHub](https://github.com/x) / - Toots on [Mastodon](https://mastodon.social/@x) loses "Code on" and "Toots on").

Relation to #5979

#5979 (closed) stops text-labelled links to social hosts being treated as icons, which may cover the reductions above in a newer release. But the underlying data loss remains for any list the pattern does accept, for example icon links or an explicitly named .social list whose items also hold other text.

Expected

  • A list whose items hold text outside their links is never lowered to core/social-links (or the pattern declines and the list converts as core/list). Social links can't hold that text, so accepting the list loses content.
  • A cluster made only of mailto: links isn't treated as social on its own. Email addresses are ordinary content far more often than a social-icon row.
  • If text must be dropped, it should at least be reported as a fallback rather than lost silently.

Workaround downstream

In LH Content Converter we now hide http/https/mailto hrefs inside lists from the transformer for Markdown input (placeholder URLs on .invalid) and restore them afterwards. We'll drop that once this is fixed.


AI disclosure: diagnosed and filed with Claude (Anthropic) via the LocalHero MCP tooling, reproduced against the live converter.

Lingua principale
PHP
Stelle
28
Fork
5
Merge medio
2h 59m
PR unite (30g)
942

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/blocks-engine

Tutte le issue di Automattic/blocks-engine

Issue simili

Altre issue su PHP

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.