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

Open
#6,308 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
52/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
php
Domain
backend

Research direction

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.

Written by the indexing model from the issue text.

Description

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.

Dominant language
PHP
Stars
28
Forks
5
Avg merge
2h 59m
Merged PRs (30d)
942

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

All issues in Automattic/blocks-engine

Similar issues

More PHP issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.